[ 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.
Web开发者常需创建表单收集用户输入,本文介绍使用ASP.NET网页创建XML文件作为表单基础。详细说明了XML表单各字段含义,还给出运行示例的步骤,包括下载解压文件、访问指定页面、加载测试表单或创建新表单等,后续将展示如何用XML表单捕获用户输入并保存结果。

8571

被折叠的 条评论
为什么被折叠?



