I have a button launching a thread when the thread is completed it calls a method that has to set the text in a label.
However it doesn't set the text.
The thread is called Async, (using a delegate).
I'm using AJAX: the label is located within an updatepanel
When trying to use the updatepanel to update the label. I get the following error:
The Update method can only be called on UpdatePanel with ID 'UpdatePanel1' before Render.
Public Delegate Sub LongTimeTask_Delegate(ByVal s As String)
Public Sub LongTimeTask(ByVal s As String)
Thread.Sleep(5000)
End Sub
Public Sub TaskCompleted(ByVal R As IAsyncResult)
Me.Label1.Text = "Bart"
Me.UpdatePanel1.Update()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim d As New LongTimeTask_Delegate(AddressOf LongTimeTask)
Dim R As IAsyncResult = d.BeginInvoke(" ", New AsyncCallback(AddressOf TaskCompleted), Nothing)
End Sub