By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,278 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,278 IT Pros & Developers. It's quick & easy.

Changing value of dynamic control in Page_Load after creating the

P: n/a
I have a multithreaded application is ASP.NET that checks the status of a
process every 2 seconds. After the thread has completed, the values of
dynamically added controls need to be changed depending on the return value
from the process just completed on the second thread. The problem I am having
is that while the code seems to work correctly (I am performing a
response.write and writting out the values as a HTML comment), the final
display to the end user shows the initial value set to the dynamic control.

Any idea why this is happening? Any help will be welcome.

Here is what I am doing:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim oThread AS CustomThreadClass
Dim oControl AS DropDownList

'build all the dynamic controls
BuildDynamicControls

'if this is a postback - check the status of the thread and change value
of dynamic control
If IsPostBack Then
oThread = Session("Threading")
If Not oThread Is Nothing Then
If oThread.Status = oThread.StatusEnum.Completed Then
'find the dynamic control by using a custom method that recursively
searches for the dynamic control
oControl = FindControlByName("lstStatus")
oControl.SelectedItem = 2
Response.Write ("<!-- Value: " & oControl.Text & " -->")
End If
End If
End If

'code to sleep for 2 seconds and refresh page goes here - will not
replicate this

End Sub
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I found the answer. The value of the dynamically loaded control must be
changed in the Page_PreRender event.

"amirmira" wrote:
I have a multithreaded application is ASP.NET that checks the status of a
process every 2 seconds. After the thread has completed, the values of
dynamically added controls need to be changed depending on the return value
from the process just completed on the second thread. The problem I am having
is that while the code seems to work correctly (I am performing a
response.write and writting out the values as a HTML comment), the final
display to the end user shows the initial value set to the dynamic control.

Any idea why this is happening? Any help will be welcome.

Here is what I am doing:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim oThread AS CustomThreadClass
Dim oControl AS DropDownList

'build all the dynamic controls
BuildDynamicControls

'if this is a postback - check the status of the thread and change value
of dynamic control
If IsPostBack Then
oThread = Session("Threading")
If Not oThread Is Nothing Then
If oThread.Status = oThread.StatusEnum.Completed Then
'find the dynamic control by using a custom method that recursively
searches for the dynamic control
oControl = FindControlByName("lstStatus")
oControl.SelectedItem = 2
Response.Write ("<!-- Value: " & oControl.Text & " -->")
End If
End If
End If

'code to sleep for 2 seconds and refresh page goes here - will not
replicate this

End Sub

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.