XML Form Generator, Part 1: Generating an XML Form
发表于2004/11/3 8:26:00 1201人阅读
[ Download Code ] | [ Run Sample ]
One of the most frequent tasks that web developers receive is that of creating a form to collect user input. One solution is to use an ASP.NET web page to create an XML file that will be used as the basis for a web form. The three part article, XML Form Generator, will demonstrate how to easily create an XML form that will save user input as an XML file. By using the run sample link above you view all the source code and see an online demo.
First, we are going to need a web page that will create an XML files (XML forms) in this format:
<?xml version="1.0" standalone="yes"?> <NewDataSet> <Fields> <Control>DropDownList</Control> <Data>String</Data> <Required>Yes</Required> <Order>3</Order> <Label>Operating System</Label> <Id>OS</Id> <Text>Windows 98,Windows XP,Other</Text> </Fields> . . . . . </NewDataSet>
Here is the explanation of the fields:
- Control - The type of ASP.NET web server control
- Data - The type of data that the form will take as input
- Required - Is the field required
- Order - The order that the fields will be displayed in the form
- Label - The field label that is displayed on the form
- Id - The ASP.NET web server control id
- Text - This field is use in multiple ways:
- For TextBox, Multiline, Hidden, Password and Label controls this is the default value (Note: Multiline, Hidden, Password are all TextBox controls)
- For DropDownList, RadioButtonList and CheckBoxList and ListBox controls a comma separated list will be displayed as separate items
- For a CheckBox control it the text displayed next to it
How to run the sample:
- Download and extract the files to a virtual directory.
- Use your web browser to navigate to the XmlFormGen.aspx file in that virtual directory.
- To load the included test form type in Test.xml and click the Load Form button.
- To create a new form type in the name of the form and add a .xml extension. Then click on the New Form button.
- You can now edit, delete, and add fields on you form.
That's all there is to creating a form. I know what you're thinking, all this does is create XML files. But, it actually creates a very specific kind of XML file that I am calling an XML form. The next part of this series will demonstrate how we can use these XML forms to capture user input and save the results to XML files.
gao_liang0420 2012-07-25 11:23 0
ID: 30798, Hotfix for Inherited VCL Form HighDPI Regression in 10.2.1 Part1
sjm001 2017-09-21 09:29 1
QQ51567242 2012-02-01 16:10 290
Extjs mvc 读取XML数据到form
xiaoyan966 2015-03-31 22:01 1042
hj7jay 2016-03-11 13:47 3147
CronousGT 2017-02-28 19:43 809
php form generator mysql db backend
u011704493 2013-08-15 16:38 1
E-FFC: an enhanced form-focused crawler for domain-specific deep web databases
jintaodu 2012-12-12 14:41 0