473,480 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dynamically Added Controls Question

I'm sure this is simple but I'm not sure how to persist dynamically created
controls.

If Not IsPostBack Then

Dim txt As New TextBox
txt.Text = "Test"

CType(Me.FindControl("Form1"), HtmlForm).Controls.Add(txt)

End If

I have a button on this simple page and when I click it the page posts back
and the textbox disappears. How can prevent this from happening?

Thanks,

Jason MacKenzie
Nov 18 '05 #1
2 929
Jason:

You have to add the control on every postback operation.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 10 Nov 2004 08:53:56 -0500, "Jason MacKenzie"
<jm**********************@formet.com> wrote:
I'm sure this is simple but I'm not sure how to persist dynamically created
controls.

If Not IsPostBack Then

Dim txt As New TextBox
txt.Text = "Test"

CType(Me.FindControl("Form1"), HtmlForm).Controls.Add(txt)

End If

I have a button on this simple page and when I click it the page posts back
and the textbox disappears. How can prevent this from happening?

Thanks,

Jason MacKenzie


Nov 18 '05 #2
Thanks Scott.

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:3t********************************@4ax.com...
Jason:

You have to add the control on every postback operation.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 10 Nov 2004 08:53:56 -0500, "Jason MacKenzie"
<jm**********************@formet.com> wrote:
I'm sure this is simple but I'm not sure how to persist dynamically
created
controls.

If Not IsPostBack Then

Dim txt As New TextBox
txt.Text = "Test"

CType(Me.FindControl("Form1"), HtmlForm).Controls.Add(txt)

End If

I have a button on this simple page and when I click it the page posts
back
and the textbox disappears. How can prevent this from happening?

Thanks,

Jason MacKenzie

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4293
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
2
4976
by: Sam | last post by:
I have a custom control (MyTextBox - taken from Microsoft website) that implements the IPostBackDataHandler interface. It is added to the controls collection of a placeholder control during the...
2
1933
by: djc | last post by:
On the page_load event I am querying a database and binding data to some text boxes, list boxes, and a repeater control. When the page loads it uses the value of one of the database fields (status)...
4
3086
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
0
2382
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event,...
5
1948
by: Chris | last post by:
I have a page with mixture of static and dynamically added controls is there any way of controlling the order which they are added to the page. My submit button (statically added) appears before...
3
1636
by: s9213037 | last post by:
Use case scenario: I have a panel with ID "Upload_Panel", where there is a FileUpload control with ID "FileUpload1" and a button with ID "More_Upload_Files", both of which are added at design...
5
4437
by: Nathan Sokalski | last post by:
I have a custom control that I wrote (I inherit from System.Web.UI.WebControls.CompositeControl). I dynamically add this control to my Page, but I was told that dynamically added controls do not...
1
4866
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
7
6625
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
7044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7084
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6929
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...
0
5337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
2995
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...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
181
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...

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.