How to Maintain view state for Runtime created Controls ???

takesoln

Newcomer
Joined
Mar 2, 2004
Messages
18
Location
Chennai
Hi ...

I am creating a Textbox within a place holder, on a Button_Click Event ... i.e. At runtime ...

But, i am not able to get the value of the text box, on PostBack ... I know that the control has to be re-created every time the page loads, but i don't know how to manage state for the dynamically created control...

My code is,

Private Sub Cash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cash.Click

Dim txtbox As New TextBox()
Dim btnOne As New Button()
txtbox.Width = Unit.Pixel(100)
txtbox.Height = Unit.Pixel(20)
btnOne.Text = "buttonClear"
PlaceHolder1.Controls.Add(txtbox)
PlaceHolder1.Controls.Add(btnOne)

'End If

End Sub

I would appreciate it if you could suggest how i can manage this control thru my code ...

If possible, give me some sample code too ...

Thanks ...
 
Back
Top