我有一个ASP.NET GridView有一列作为链接 - 推动链接触发JQuery调用并打开一个fancybox。一切工作,直到我把我的代码在UpdatePanel。jquery不能在ASP.NET UpdatePanel中工作
一旦进入UpdatePanel,链接不再起作用。如果我将所有内容全部从UpdatePanel中取出,那么所有工作都会正常工作。
如何让JQuery识别updatePanel中的GridView链接?
$("a.grid").click(function() {
var ID = this.id;
$.fancybox({
'scrolling': true,
'autoSize': false,
'width': 1015,
'height': 515,
'transitionIn': 'fade',
'transitionOut': 'fade',
'speedIn': 200,
'speedOut': 300,
'type': 'iframe',
'href': 'general_stats.aspx?ID=' + ID
});
});
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataSourceID="SqlDataSourceGenStats1" Font-Size="Smaller"
ForeColor="#4C98AA" GridLines="None" Width="669px" Visible="False">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="PERSON_ID" HeaderText="Person ID"
SortExpression="PERSON_ID" />
<asp:BoundField DataField="FIRST_NAME" HeaderText="First Name"
SortExpression="FIRST_NAME" />
<asp:BoundField DataField="LAST_NAME" HeaderText="Last Name"
SortExpression="LAST_NAME" />
<asp:TemplateField HeaderText="View Stats">
<ItemTemplate>
<a class="grid" id="<%# Eval("PERSON_ID") %>" href="#">View</a>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#4C98AA" Font-Bold="True" ForeColor="White"
HorizontalAlign="Left" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
使用Javascript/jQuery代码将永远不会被从Ajax响应(你的更新面板)执行。 – Sai
您使用的是标签吗? –