forum

Home / DeveloperSection / Forums / UpdatePanel does not update

UpdatePanel does not update

Takeshi Okada 1792 28-Aug-2014

I have an asp.net website which contains a Thread that fetches some data from a WCF service. That thread runs in an infinite loop waiting each run for 1 second. Now I would like to show the stuff it got from the WCF service in a label. I added that label to an UpdatePanel and invoked the .Update() method. I don't get any exceptions, however, the label does not update at all. Here is my code (simplified):

t = new Thread(new ThreadStart(() =>
{
   while (true)
   {
      Label1.Text = GetFromWCF() + " " + DateTime.Now.ToString();
      updatePanel.Update();
      Thread.Sleep(1000);
   }
}
));
t.IsBackground = true;
t.Start();

This code is in the OnInit Method of the page. The updatePanel looks like this:

<asp:ScriptManager runat="server" ID="scriptManager" EnablePartialRendering="true"/>
<asp:UpdatePanel runat="server" ID="updatePanel" UpdateMode="Conditional">
   <ContentTemplate>
      <asp:Label ID="Label1" runat="server" />
   </ContentTemplate>
</asp:UpdatePanel>

Am I missing anything? Maybe I should also inform you that I am very new to asp.net.


Updated on 30-Sep-2014

Can you answer this question?


Answer

2 Answers

Liked By