UpdateProgress not showing with custom postback
I have a page with an UpdateProgress and and UpdatePanel.
I want to trigger a postback in the UpdatePanel immediately after the page
has completed loading, so implemented a custom control, called
UpdateTrigger that just causes a postback once:
public partial class UpdateTrigger : System.Web.UI.UserControl {
public event EventHandler<EventArgs> Tick;
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
Page.ClientScript.RegisterStartupScript(GetType(), ClientID,
string.Format("<script type='text/javascript'>{0}</script>",
Page.ClientScript.GetPostBackEventReference(this, "")));
} else {
if (object.ReferenceEquals(sender, this) && Tick != null) {
Tick(this, EventArgs.Empty);
}
}
}
}
Then, in my aspx page, I put my custom control inside an UpdatePanel, like
this:
<asp:UpdateProgress ID="UpdateProgress1" runat="server"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>Loading...</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<ut:UpdateTrigger ID="UpdateTrigger1" runat="server"
OnTick="UpdateTrigger1_Tick"/>
</ContentTemplate>
</asp:UpdatePanel>
The only problem is that the UpdateProgress is not displayed on the
postback, while if I use a Timer it works perfectly (of course, the reason
I did all this is because I don't want to use a Timer).
According to this documentation (Programming UpdateProgress Controls in
Client Script), the UpdateProgress should be displayed if the postback is
caused by a control inside the associated UpdatePanel, but in this case it
does not seem to work.
What am I missing?
No comments:
Post a Comment