我的div“附件”在回复后没有刷新,并且没有调用pageLoad()
<div id ="attachments">
<asp:UpdatePanel ID="updtPnlAttachements" runat ="server" >
<ContentTemplate>
<asp:GridView ID="gvAttachments" runat="server" ClientIDMode = "Static" Width ="100%">
<Columns>
</Columns>
<EmptyDataTemplate>
<div> Sorry Empty</div>
</EmptyDataTemplate>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
拨打此按钮后
public void ReportLinkButton_Click(object sender, EventArgs e)
{
LinkButton Lbtn = (LinkButton)sender;
string assessmentString = Lbtn.CommandArgument;
Guid assessmentID = new Guid(assessmentString);
DR_Data db = new DR_Data();
var reports = db.GetAttachmentsByAssessmentID(assessmentID).ToList();
gvAttachments.DataSource = reports;
gvAttachments.DataBind();
if (reports.Count() > 0)
{
gvAttachments.HeaderRow.TableSection = TableRowSection.TableHeader;
gvAttachments.FooterRow.TableSection = TableRowSection.TableFooter;
}
}
我的脚本看起来像这样
function pageLoad() {var totalRows = $("#<%=gvAttachments.ClientID %> tr").length;
if (totalRows > 0) {
$("#dialog:ui-dialog").dialog("destroy");
$("#attachments").dialog({
hide: "fold",
show: "blind",
height: 500,
width: 800,
modal: true
});
}
$('#gvNcReports').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
});
}`
任何建议。感谢
的 的 *更新**
我有多个更新面板,一旦删除它就可以了。
答案 0 :(得分:0)
尝试:
using Sys.Application.add_load(function(sender, e) {
});
看看这是否有所作为。更新面板请求结束时,您也可以使用
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function(sender, e) {
});
HTH。
答案 1 :(得分:0)
II最终将此添加到Page_Load并且可以正常工作
string script = @"<script>
function pageLoad() {
$('#gvNcReports').dataTable({
"bJQueryUI": true,
"bPaginate": false
});
$("#dialog:ui-dialog").dialog("destroy");
$("#updtPnlAttachements").dialog({
hide: "fold",
show: "blind",
height: 500,
width: 800,
modal: true
});
}
});</script>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"hover",script);
但是我仍然需要在标题中添加$(document).ready和相同的脚本以确保在最初呈现时一切正常,这是不好的做法吗?