0
我有一个listview,我需要添加一个弹出窗口打开右键单击事件。目前我已经用jQuery实现了它。但是页面的初始加载,右键不起作用。但是,如果我刷新页面,然后右键单击正在工作。我已经查看html源代码,并且可以正确加载所有标记和jquery变量。asp.net listview item的Rigth点击事件
这是我的标记。
<asp:ListView ID="lvKeywords" OnItemDataBound="lvKeywords_ItemDataBound" OnItemDeleting="lvKeywords_ItemDeleting"
DataKeyNames="Key" runat="server" OnItemUpdating="lvKeywords_OnItemUpdating" >
<ItemTemplate>
<div id="<%#Eval("Key") %>" class="fsKeywordItem">
<asp:Literal ID="ltrlKeyword" runat="server"></asp:Literal>
</div>
<%--this is the popup--%>
<div class="smartPopUp" id="<%#Eval("Suggession") %>" style="display: none;">
<%-- there are some html controls here --%>
</div>
<script type="text/javascript">
$(document).ready(function() {
$("#" + '<%#Eval("Key") %>').mousedown(function (event) {
switch (event.which) {
case 3:
event.preventDefault();
showPopup('<%#Eval("Suggession") %>');
}
});
$("#" + '<%#Eval("Key") %>').bind("contextmenu", function (e) {
e.preventDefault();
});
});
</script>
</ItemTemplate>
</asp:ListView>
<script type="text/javascript">
function showPopup(divId) {
$("#" + divId).css("display", "block");
}
</script>
有关此问题的任何想法?
检查它 http://www.codeproject.com/Articles/63902/Right-Click-Menu-using-JQuery-ASP-NET-using-C – 2013-04-24 04:24:06