In the .aspx code I set up a timer, TimerRefresh
but leave it turned off. Then when the page begins loading if this is not a PostBack (the first time) I turn on TimerRefresh
. It immediately ticks. This causes a page reload which will be a PostBack. This causes UpdateProgress1
to show. PageLoad()
will do nothing because this is a PostBack. TimerRefresh_Tick(object sender, Eventargs e)
fires because this was triggered from the timer ticking. This causes it to turn off the timer from running again and loads the page with data. As soon as it is complete UpdateProgress1
goes away.
In Page_Load()
if (!IsPostBack)
{
TimerRefresh.Enabled = true;
}
In TimerRefresh_Tick(object sender, EventArgs e)
TimerRefresh.Enabled = false;
codeToLoadDate();
The .aspx
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="10">
<ProgressTemplate>
<div id="updatestatus" class="shadow">
<asp:Label ID="Label12" runat="server" Text="Loading...">
</asp:Label>
<asp:Image ID="Image1"
runat="server" ImageUrl="~/images/1status.png" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="TimerRefresh" runat="server" Interval="100"
ontick="TimerRefresh_Tick" Enabled="False">
<%-- My page loading stuff - controls that would hold data -->
</ContentTemplate>
</asp:UpdatePanel>