My div "attachements" is not refreshing after a post back and pageLoad() is not being called
<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>
After making this button call
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.TableSec开发者_如何转开发tion = TableRowSection.TableFooter;
}
}
My script looks like this
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"
});
}`
any suggestions. Thanks
*UPDATE**
I had multiple update panels, once I removed them it worked.
Try :
using Sys.Application.add_load(function(sender, e) {
});
And see if that makes a difference. You can also use, when the update panel request ends:
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function(sender, e) {
});
HTH.
II ended up adding this to Page_Load and it works
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);
However I still have to add $(document).ready and the same script in the header to make sure everything works when it initially renders, is this bad practice?
精彩评论