473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 6333
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.