Dynamically creating a web form with server controls

G

Guest

I want to define a set of web-form templates in XML and render the equivalent
web-form with ASP.NET, then process any input server controls on the form.

Reading the XML file from Page_load is easy, but
1) How do I set about dynamically creating user controls (like TextBox,
TextArea)
--- simply Declare and initialised (new) the user controls?? How do I
"place" it graphically on the form. Ideally, I want them to lay out in a
table, one by one.

2) How do I wire up the user controls to page submission handling?
 
K

Kevin Yu [MSFT]

Hi,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
S

Steven Cheng[MSFT]

Hi,

From your description, you have defined a certain XML template which
contains the info of how a webform page's layout(webcontrols on the page )
are included and positioned, and you're wondering how to correctly add
those configured controls dynamically onto the webform page, yes?

As for this question, this is a typical "programmatically creating and
adding web server controls onto page" problem. Generally we should take
care on the following things when adding dynamic controls onto page:

1. As for creating , it'll be better if we can create those dynamic
controls in Init event though Page_load is also ok. And the most important
thing is that we need to create the controls in every request (not only the
intial request like IsPostBack==true)

2. For postback event handler for dynamic created controls, we also need
to add them everytime the page is executed. Also, we need to put the event
handler registering code before the page's post back event happending
(generally in page_init or Page_Load is ok)

Anyway, if you're not very familiar with the ASP.NET's page processing
model(events and viewstate mechanism....), I suggest you have a look at the
following tech articles which may help us have a more detail idea on the
problems we may meet when creating dynamic webpage UI:

#Creating Dynamic Data Entry User Interfaces
http://msdn.microsoft.com/library/en-us/dnaspp/html/dynamicui.asp?frame=true

#Understanding ASP.NET View State
http://msdn.microsoft.com/library/en-us/dnaspp/html/viewstate.asp

#HOW TO: Dynamically Create Controls in ASP.NET by Using Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;317794

If there're any further problems, please feel free to post here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top