473,775 Members | 2,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing value of dynamic control in Page_Load after creating the

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.EventArg s) Handles MyBase.Load

Dim oThread AS CustomThreadCla ss
Dim oControl AS DropDownList

'build all the dynamic controls
BuildDynamicCon trols

'if this is a postback - check the status of the thread and change value
of dynamic control
If IsPostBack Then
oThread = Session("Thread ing")
If Not oThread Is Nothing Then
If oThread.Status = oThread.StatusE num.Completed Then
'find the dynamic control by using a custom method that recursively
searches for the dynamic control
oControl = FindControlByNa me("lstStatus" )
oControl.Select edItem = 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
1 2704
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.EventArg s) Handles MyBase.Load

Dim oThread AS CustomThreadCla ss
Dim oControl AS DropDownList

'build all the dynamic controls
BuildDynamicCon trols

'if this is a postback - check the status of the thread and change value
of dynamic control
If IsPostBack Then
oThread = Session("Thread ing")
If Not oThread Is Nothing Then
If oThread.Status = oThread.StatusE num.Completed Then
'find the dynamic control by using a custom method that recursively
searches for the dynamic control
oControl = FindControlByNa me("lstStatus" )
oControl.Select edItem = 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7587
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
2
388
by: hb | last post by:
Hi, I have a page that uses dynamic generated web user control. On the eupdate.aspx, I get: === <asp:table id="tblE" runat="server"> <asp:tablerow id="rE" runat="server"> <asp:tablecell id="cE" runat="server" /> </asp:tablerow> </asp:table>
1
3352
by: Henke | last post by:
Hello, I have one ImageButton controls which I initialize in Page_Load and declare on class level. ImageButton save = new ImageButton(); save.ImageUrl = "save.gif" save.Click += new ImageClickEventHandler(this.save_click); This ImageButton is added to a dynamic table which is also
13
3674
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page first starts, but when I click on a button, and the page comes back, my dynamically created grid and controls are not visible. Any thoughts? Please view my sample code below. If Not ispostback then creategrids end if
3
3985
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which step you're on. This all works fine, but I ran into some trouble when I started creating controls dynamically in my code-behind file. Each panel contains a table which is filled with various radio buttons, text fields and the such which are...
1
1263
by: Adrian Parker | last post by:
At postback time, the controls are all recreated before an event fires. If the event determines that some of the controls need to be replaced with different controls that you can't create as invisible beforehand, how do you go about it ? Can you force a re-run of the control creation step ? Thanks Adrian Parker
2
2937
by: Ben Amada | last post by:
I'm a little confused about in what Event should I add dynamic controls and in what Event should I retrieve the value of a dynamic control on postback. I've found that adding dynamic controls in the Page Load event works, and I realize that I need to add the dynamic controls again on each postback. But if I'm trying to retrieve the value of a dynamic control (Text property of a TextBox for instance), should I retrieve the value in the...
2
1646
by: mivhaelveloz | last post by:
I thought I had a good grip on viewstate handling, but am suprised by a small test: In my aspx file I have a PlaceHolder control and a button for posting back. Dynamically in Page_Load I create a TextBox, and add it as a control of PlaceHolder. I do this regardless of whether IsPostBack is true or not, to insure
3
2111
by: s.bussing | last post by:
Hi, I have been reading for hours now, but I'm still not able to solve my problem, though a lot of people are struggling with something similar. On my page I have a nested repeater. In the inner repeater for each item a usercontrol is added which has a textbox and two buttons. No I know that when the page is posted back (in my case by pushing one of the buttons of the control), I have to recreate all the dynamic control. I want to...
0
9622
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10048
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6718
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.