By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,795 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,795 IT Pros & Developers. It's quick & easy.

Dynamically creating a web form with server controls

P: n/a
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?
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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."

Nov 19 '05 #2

P: n/a
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...asp?frame=true

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

#HOW TO: Dynamically Create Controls in ASP.NET by Using Visual C# .NET
http://support.microsoft.com/default...b;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.)

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.