c# - How do I update a page during an asynchronous postback? -


i'm stumped. attempting show progress bar while site executes query. query takes anywhere 4-6 minutes. progress bar gets value database, oracle has built-in query provide values progress bar. i'm using essentialobjects' progressbar. set "value" integer between 1 , 100.

here simplified version of code:

page:

 <asp:updatepanel id="upquery" runat="server">     <contenttemplate>         <asp:button id="btnexecute" runat="server" onclick="btnexecute_click" />     </contenttemplate> </asp:updatepanel> <asp:updatepanel id="upprogress" runat="server">     <contenttemplate>         <asp:timer id="tmr" runat="server" enabled="false"                     ontick="tmr_tick" interval="3000"></asp:timer>         <eo:progressbar id="pbr" runat="server" ></eo:progressbar>     </contenttemplate> </asp:updatepanel> 

code:

protected void btnexecute_click(object sender, eventargs e) {         tmr.enabled = true;         executelongquery(); }  protected void tmr_tick(object sender, eventargs e) {         pbr.value = getprogress(); } 

basically when click btnexecute, timer doesn't start until postback has completed, making progress bar never show. tried callback, not sure if did right, page wouldn't show result during postback. how timer (or anything) respond while page in async postback?

the fact you've enabled timer isn't passed client until postback completed. that's how works. executing code on server doesn't have immediate effect on client. if you're waiting executelongquery() complete before sending response client you'll never see timer.

your best bet run executelongquery() in seperate thread on server, allowing postback complete , timer start.

i suggest reading on asp.net page lifecycle - this looks place start.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -