469,640 Members | 1,554 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,640 developers. It's quick & easy.

Dynamically creating a web form with server controls

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,
--- 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?
Nov 19 '05 #1
2 4298

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

Nov 19 '05 #2

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

#Understanding ASP.NET View State

#HOW TO: Dynamically Create Controls in ASP.NET by Using Visual C# .NET

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

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Bas Groeneveld | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.