473,472 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dynamic Controls and Postback

I am creating a set of dynamic text boxes on my page.

When I do a postback the dynamic controls seem to always disappear. I have
tried setting the EnableViewstate = True and still no luck. I would like
them to remain and persist any data entered by the user on postback.

Any ideas?

-Steve

Nov 17 '05 #1
4 6337
Steve,

They'll need to be recreated everytime. The veiwstate only stores
information about the control, not the control it self.

-- Alex Papadimoulis
"Steve Roszko" <sr*****@MeNoLikeSpammmBikeReg.com> wrote in message
news:eT*************@TK2MSFTNGP12.phx.gbl...
I am creating a set of dynamic text boxes on my page.

When I do a postback the dynamic controls seem to always disappear. I have tried setting the EnableViewstate = True and still no luck. I would like
them to remain and persist any data entered by the user on postback.

Any ideas?

-Steve

Nov 17 '05 #2
Steve,

They'll need to be recreated everytime. The veiwstate only stores
information about the control, not the control it self.

-- Alex Papadimoulis
"Steve Roszko" <sr*****@MeNoLikeSpammmBikeReg.com> wrote in message
news:eT*************@TK2MSFTNGP12.phx.gbl...
I am creating a set of dynamic text boxes on my page.

When I do a postback the dynamic controls seem to always disappear. I have tried setting the EnableViewstate = True and still no luck. I would like
them to remain and persist any data entered by the user on postback.

Any ideas?

-Steve

Nov 17 '05 #3
> They'll need to be recreated everytime. The veiwstate only stores
information about the control, not the control it self.
-- Alex Papadimoulis

Yeah, that's what conclusion I seemed to come to but thought I'd see if I
was missing something. Here is some code for basically how I solved it.

ASPX PAGE

<body>
<form id="Form1" method="post" runat="server">
<asp:Button Runat=server ID=btnAdd Text=Add />
<asp:Button Runat=server ID=btnPost Text=Post/>
<asp:PlaceHolder ID=place Runat=server EnableViewState=True />
</form>
</body>
CODE BEHIND

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()

'--> RECREATE DYNAMIC CONTROLS IF NEEDED <--
If Request.Form("txtb") <> "" Then
Dim txtbox As New TextBox
txtbox.Text = Request.Form("txtb")
txtbox.ID = "txtb"
txtbox.EnableViewState = True

Me.place.Controls.Add(txtbox)

End If
End Sub

Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Dim txtbox As New TextBox
txtbox.Text = Now.ToString
txtbox.ID = "txtb"
txtbox.EnableViewState = True

Me.place.Controls.Add(txtbox)

End Sub
-Steve

Nov 17 '05 #4
> They'll need to be recreated everytime. The veiwstate only stores
information about the control, not the control it self.
-- Alex Papadimoulis

Yeah, that's what conclusion I seemed to come to but thought I'd see if I
was missing something. Here is some code for basically how I solved it.

ASPX PAGE

<body>
<form id="Form1" method="post" runat="server">
<asp:Button Runat=server ID=btnAdd Text=Add />
<asp:Button Runat=server ID=btnPost Text=Post/>
<asp:PlaceHolder ID=place Runat=server EnableViewState=True />
</form>
</body>
CODE BEHIND

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()

'--> RECREATE DYNAMIC CONTROLS IF NEEDED <--
If Request.Form("txtb") <> "" Then
Dim txtbox As New TextBox
txtbox.Text = Request.Form("txtb")
txtbox.ID = "txtb"
txtbox.EnableViewState = True

Me.place.Controls.Add(txtbox)

End If
End Sub

Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Dim txtbox As New TextBox
txtbox.Text = Now.ToString
txtbox.ID = "txtb"
txtbox.EnableViewState = True

Me.place.Controls.Add(txtbox)

End Sub
-Steve

Nov 17 '05 #5

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

Similar topics

1
by: Scott Schluer | last post by:
Hello, I've got myself a small problem and I'm hoping someone can help. I have a DataList called dlProducts (displays products from a database). Within the <ItemTemplate> container of the...
13
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...
2
by: Dave Williamson | last post by:
When a ASPX page is created with dynamic controls based on what the user is doing the programmer must recreate the dynamic controls again on PostBack in the Page_Load so that it's events are wired...
3
by: Tyler Carver | last post by:
I am trying to use some dynamic controls that are built and then added to tables. The problem that I am having is the timing of when I can populate the controls and have the state remain after a...
5
by: PCH | last post by:
I have an c# asp.net (.net 1.1) web page, viewstate on. The problem I am having is on the button click postback to update. Heres the situation: I have an asp table that has 1 header row. ...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
2
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation...
4
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example...
0
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,...
0
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
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...
1
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.