0
我想顯示在gridview中的每一行的上下文菜單。asp.net gridview jquery contextmenu
上下文菜單需要傳遞每行的特定變量,例如,唯一的用戶標識。
我想了ul只在頁面上一次我已經過了變量或東西
<ul id="myMenu" class="contextMenu">
<script src="scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="scripts/jquery.contextMenu.js" type="text/javascript"></script>
<link href="jquery.contextMenu.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(document).ready(function() {
// Show menu when #myDiv is clicked
$("img").contextMenu({
menu: 'myMenu'
},
function(action, el, pos) {
alert(
'Action: ' + action + '\n\n' +
'Element ID: ' + $(el).attr('id') + '\n\n' +
'X: ' + pos.x + ' Y: ' + pos.y + ' (relative to element)\n\n' +
'X: ' + pos.docX + ' Y: ' + pos.docY+ ' (relative to document)'
);
});
});
</script>
<form id="form1" runat="server">
<div>
<asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="imgPop" runat="server" ImageUrl="~/images/pop.gif" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="First Name" DataField ="FirstName" />
<asp:BoundField HeaderText="Last Name" DataField ="LastName" />
</Columns>
</asp:GridView>
<ul id="myMenu" class="contextMenu">
<li class="edit"><a href="#edit">Edit</a></li>
<li class="cut separator"><a href="#cut">Cut</a></li>
<li class="copy"><a href="#copy">Copy</a></li>
<li class="paste"><a href="#paste">Paste</a></li>
<li class="delete"><a href="#delete">Delete</a></li>
<li class="quit separator"><a href="#quit">Quit</a></li>
</ul>
</div>