I'm writing my first web application using C# ASP.NET. I have a socket client running in the CodeBehind that connects to an application running a socket server. I have controls in the ASP page that I want to update whenever the server notifies me of a state change. So for instance, if I have a Label contained in an UpdatePanel, I want to change the text if the server tells me it has changed. I have a callback function that gets called whenever the server sends me data that looks like this:
private void DataReceived(string data)
{
labelStatus.Text = ParseData(data);
}
ParseData just gets the desired text out of the data. However, the Label does not get updated because there is no PostBack.
What I have tried:
If I store the data in a static variable and run a timer to continually check to see if there is any unhandled data available, it will work because the timer triggers a PostBack event. Although it works, it is undesirable because the page is constantly refreshing even if nothing is changing.
Is there any way to update the label without using a timer?