URGENT!!!!!!!!!!!!!

R

Ravindra

Hi All

I generate several HtmlInputText controls at runtime
(could be any number of HtmlInputTexts,depending on
database value). I can view them without any problem by
adding them to the html table on my aspx page.
On postback,I need to collect data from the HtmlInputTexts
to submit to the server. So I want to find the dynamically
generated HtmlInputText controls. However, i can't
find the HtmlInputText controls. WHY???

Any Suggestions will be of great help

Thx in advance
Ravindra
 
H

Hermit Dave

Ravindra,

You have a class and after it is initialised, in a method call you create an
output string based on certain conditions. you are done with the class and
you unload it.
you need it again and you create an instance of the class again. you do have
the same output stream without the conditional data by default ?

Similarly in ASP.NET you page is just a class derived from Page Class. You
run time members are not a part of class as such when its created rather
they are a part of the output stream
Hence on postback they are not instantiated. And since event delegation
happens after postback you cant find you objects

I would say use placeholder and add your dynamic controls to the place
holder.

MSDN links
Adding PlaceHolder Web Server Controls to a Web Forms Page
Add a PlaceHolder Web server control to your page when you want to
dynamically add, remove, or loop through controls at run time.
http://msdn.microsoft.com/library/en-us/vbcon/html/vbtskaddingplaceholdercontrolstowebformspage.asp

PlaceHolder Web Server Control
The PlaceHolder control enables you to place an empty container control in
the page and then dynamically add child elements to it at run time.
http://msdn.microsoft.com/library/en-us/vbcon/html/vboriplaceholderwebservercontrol.asp

Introduction to the PlaceHolder Web Server Control
The PlaceHolder Web server control enables you to place an empty container
control within the page and then dynamically add, remove, or loop through
child
http://msdn.microsoft.com/library/en-us/vbcon/html/vbconplaceholderwebservercontrol.asp

BasePlaceholderControl Members (Site Development)
BasePlaceholderControl overview
http://msdn.microsoft.com/library/e...ontrolsbaseplaceholdercontrolmemberstopic.asp

PlaceHolder Web Server Control (.NET Framework General Reference)
Reserves a location in the page control hierarchy for controls that are
added programmatically.
http://msdn.microsoft.com/library/en-us/cpgenref/html/gnconPlaceHolderWebServerControl.asp

Regards,

HD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top