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