Groups | Blog | Home
all groups > asp.net webcontrols > october 2003 >

asp.net webcontrols : Adding Controls Dynamically


Prabhu Ram Prasath
10/28/2003 10:42:12 PM
Dear Friend,

Does anyone could answer this simple problem!!!

I have a textbox, submit button and a panel (all webserver
controls) in a web page.

After entering some text in the textbox and pressing the
submit button, it will add the text into the panel as a
Hyperlink.

The code in the command button is
newCtrl = New WebControls.HyperLink
newCtrl.Text = textbox1.Text & "<BR>"
newCtrl.ID = textbox1.Text
panel1.Controls.Add(newCtrl)

The procedure is running well, but the next time I press
the button, the old hyperlink gets destroyed and only the
new hyperlink gets displayed in the panel.

Any Idea!!!

Regards,
Wesam
10/29/2003 3:30:56 PM
Probably the insertion happens by posting data (the newly inserted link) to
the WEB server, and thus it is added; likewise when you add another one, the
list (the panel) is emptied as if you'd started the application for the
first time and thus you lose the old data and only see the new ones (the new
link).

We$am

[quoted text, click to view]

AddThis Social Bookmark Button