Maybee I'm thinking of this the wrong way, I know the page renders and is sent to the client(webbrowser). But I really need to get to understand this.QuestionHow do I update my three updatepanels asynchronously? To simulate this I have created a for loop which adds a second each time, after correct number is found and event is fired.So what I want to do is to be able to see in the webbrowser, when these updates are done.The time span would be like this:TIME
0,0235(just a number toshow it really happens quick)
What happens on the page?Almost instantly first label get's updated with number 7TIME
0,0235 + one second = 1,0235 What happens on the page?Almost instantly second label get's updated with number 8TIME
0,0235 + one second = 2,0235 What happens on the page?Almost instantly third label get's updated with number 9I ahve visted pages that first show you some text and after a couple of seconds they show you a diagram, when that request has finished loading? So there must be a way rigth?Heres my code, I'm not posting my CounterEventArgs class it works and doesn't affect the question.Here's my index.aspx - codebehindpublic partial class _Default : System.Web.UI.Page{ private testClass _testet;\[code\]protected void Page_Load(object sender, EventArgs e){ ScriptManager1.RegisterAsyncPostBackControl(Button1); }void _testet_CounterFoundNumber(object sender, CounterEventArgs e){ switch (e.labelnumber) { case 1: Label1.Text = e.positionen.ToString(); break; case 2: Label2.Text = e.positionen.ToString(); break; case 3: Label3.Text = e.positionen.ToString(); break; } }protected void Button1_Click(object sender, EventArgs e){ testClass testet = new testClass(); _testet = testet; _testet.CounterFoundNumber += new testClass.CounterEventArgsHandler(_testet_CounterFoundNumber); _testet.count();}}\[/code\]And the Source\[code\] <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Async="true"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"><title></title></head><body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /></div><asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"></asp:ScriptManager><asp:UpdatePanel ID="updatepanel1" runat="server" UpdateMode="Always"><ContentTemplate><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></form></ContentTemplate></asp:UpdatePanel> <asp:UpdatePanel ID="updatepanel2" runat="server" UpdateMode="Always"><ContentTemplate> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></form></ContentTemplate></asp:UpdatePanel> <asp:UpdatePanel ID="updatepanel3" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional"><ContentTemplate>\[/code\] And lastly my testclass\[code\]public class testClass{public event CounterEventArgsHandler CounterFoundNumber; public delegate void CounterEventArgsHandler(object sender, CounterEventArgs e);public int y = 1; protected virtual void OnCounterFoundNumber(CounterEventArgs e) { if (CounterFoundNumber != null) CounterFoundNumber.BeginInvoke(this, e, new AsyncCallback(this.ResultFoundNumber), null); } public void count() { for (int i = 0; i < 10; i++) { if (i >= 7) { OnCounterFoundNumber(new CounterEventArgs(i,y)); y++; System.Threading.Thread.Sleep(1000); } } } public void ResultFoundNumber(IAsyncResult ar) { CounterFoundNumber.EndInvoke(ar); }}\[/code\]
0,0235(just a number toshow it really happens quick)
What happens on the page?Almost instantly first label get's updated with number 7TIME
0,0235 + one second = 1,0235 What happens on the page?Almost instantly second label get's updated with number 8TIME
0,0235 + one second = 2,0235 What happens on the page?Almost instantly third label get's updated with number 9I ahve visted pages that first show you some text and after a couple of seconds they show you a diagram, when that request has finished loading? So there must be a way rigth?Heres my code, I'm not posting my CounterEventArgs class it works and doesn't affect the question.Here's my index.aspx - codebehindpublic partial class _Default : System.Web.UI.Page{ private testClass _testet;\[code\]protected void Page_Load(object sender, EventArgs e){ ScriptManager1.RegisterAsyncPostBackControl(Button1); }void _testet_CounterFoundNumber(object sender, CounterEventArgs e){ switch (e.labelnumber) { case 1: Label1.Text = e.positionen.ToString(); break; case 2: Label2.Text = e.positionen.ToString(); break; case 3: Label3.Text = e.positionen.ToString(); break; } }protected void Button1_Click(object sender, EventArgs e){ testClass testet = new testClass(); _testet = testet; _testet.CounterFoundNumber += new testClass.CounterEventArgsHandler(_testet_CounterFoundNumber); _testet.count();}}\[/code\]And the Source\[code\] <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Async="true"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"><title></title></head><body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /></div><asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"></asp:ScriptManager><asp:UpdatePanel ID="updatepanel1" runat="server" UpdateMode="Always"><ContentTemplate><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></form></ContentTemplate></asp:UpdatePanel> <asp:UpdatePanel ID="updatepanel2" runat="server" UpdateMode="Always"><ContentTemplate> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></form></ContentTemplate></asp:UpdatePanel> <asp:UpdatePanel ID="updatepanel3" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional"><ContentTemplate>\[/code\] And lastly my testclass\[code\]public class testClass{public event CounterEventArgsHandler CounterFoundNumber; public delegate void CounterEventArgsHandler(object sender, CounterEventArgs e);public int y = 1; protected virtual void OnCounterFoundNumber(CounterEventArgs e) { if (CounterFoundNumber != null) CounterFoundNumber.BeginInvoke(this, e, new AsyncCallback(this.ResultFoundNumber), null); } public void count() { for (int i = 0; i < 10; i++) { if (i >= 7) { OnCounterFoundNumber(new CounterEventArgs(i,y)); y++; System.Threading.Thread.Sleep(1000); } } } public void ResultFoundNumber(IAsyncResult ar) { CounterFoundNumber.EndInvoke(ar); }}\[/code\]