【发布时间】:2016-08-30 05:56:35
【问题描述】:
在我的应用程序中,我有一个 jQuery 函数,我想从 gridview 链接按钮调用这个函数。我尝试了此处显示的代码,但未调用该函数:
<script type="text/javascript">
$(function () {
var JavascriptBlah = '<%=msUntilFour%>'
var fileName = '<%=msUntilFour%>';
$('input[id$="lnkCustomer"]').click(function () {
$("#dialog").dialog({
modal: true,
title: fileName,
width: 600,
height: 600,
buttons: {
Close: function () {
$(this).dialog('close');
}
},
open: function () {
var object = "<object data=\"{FileName}\" type=\"application/pdf\" width=\"700px\" height=\"700px\">";
object += "If you are unable to view file, you can download from <a href = \"{FileName}\">here</a>";
object += "</object>";
object = object.replace(/{FileName}/g, "Doc/Demo.pdf");
$("#dialog").html(object);
}
});
});
});
</script>
Aspx 标记:
<asp:GridView ID="gridView1" runat="server" CssClass="mydatagrid"
HeaderStyle-CssClass="header" RowStyle-CssClass="rows"
AutoGenerateColumns="false"
PageSize="10" EmptyDataText="No Records Available">
<HeaderStyle CssClass="header"></HeaderStyle>
<PagerStyle ForeColor="Red" HorizontalAlign="Center"></PagerStyle>
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:TemplateField HeaderText="CustomerID">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lnkCustomer" Text='<%#Eval("Name") %>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="rows"></RowStyle>
</asp:GridView>
</div>
<div id="dialog" style="display: none">
如何从 gridview 链接按钮调用 jQuery 函数?
提前致谢。
【问题讨论】:
-
这个link 会帮助你。
-
Thnq @devansh-nigam。它正在工作
-
如果您认为我的评论有用,请点赞。谢谢。
标签: c# jquery asp.net gridview