Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Best way to build a form dynamically

Reply
Thread Tools

Best way to build a form dynamically

 
 
Codex Twin
Guest
Posts: n/a
 
      02-14-2005
Hello Control Builders::

Part of the form that I am designing has to be built dynamically. I
ultimately want to create a set of controls that are defined somehow in the
database as part of the form. I am mulling over the design on how to
implement this and I do not know what the best way to do that would be.

One idea I have considered is to write a control which uses a ControlBuilder
class. So I have the following attributes heading my custom control,
DynamicFormBuilder:

[ParseChildren(false)]
[ControlBuilder(typeof(MetaPropertyControlBuilder))]
public class DynamicFormBuilder : WebControl, INamingContainer
{...}

The class called MetaPropertyControlBuilder specified in the ControlBuilder
attribute above is a separate class that inherits from the
System.Web.UI.ControlBuilder class.

Following on, I need to pass in an XML representation of the child controls
that the control will contain. For this, I would create an XML file from the
database (by serialization I guess) that contains a definition of the
child-controls that are to be created by this Control.

The XML file would be something like this:

<ControlTextBox PropDefId="1" label="Name" name="txtName" />
<ControlTextBox PropDefId="2" label="Reference Number" name="txtRefNumber"
/>
<ControlTextBox PropDefId="3" label="Department" name="txtDepartment" />
<ControlDatePicker PropDefId="4" label="From" name="dateProjectFromDate" />

The second attribute specifies ParseChildren(false) which means that the
MetaPropertyFormCreator will read the child XML tags that we have specified,
and then proceed to parse the XML tags and return the type that we specify
to be associated with that tag. This is done by overriding the
GetChildControlType() method in the DynamicFormBuilder control.

Then from the XML, <ControlTextBox> tag would represent a textbox control
and a <ControlDatePicker> would return the type of a DatePicker control. The
additional attributes are properties that I would like to pass to the
created control. Hence the name is the name I wish to pass on as the id of
the control. And the label as the text to be used in the preceding TableCell
of the row that the control is contained in.

However, I am not still not sure how I would pass in the XML that is created
from the database to the control at run time.

Is this the way that anyone has used? Or am I barking completely up the
wrong tree and missed out lots of essential implementation? Bear in mind
that the above explanation is a gloss-over of creating a Control that uses
ControlBuilder.
I would be grateful if someone can suggest something better/easier?

Many thanks




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to build a control for a recursive relationship hardieca@hotmail.com ASP .Net 2 03-03-2007 09:08 AM
Treeview, is there a way to build one dynamically with SQL Data? uncensored ASP .Net 0 10-30-2006 02:01 PM
Are wizard controls the best way to build a multi-step form? Alan Silver ASP .Net 0 05-30-2006 03:30 PM
Best way to build up XHTML Bart van den Burg Perl Misc 5 01-13-2005 10:13 AM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI vvcd Computer Support 0 09-25-2004 01:38 AM



Advertisments