XML Form Generator, Part 1: Generating an XML Form

[ 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:

  1. Download and extract the files to a virtual directory.
  2. Use your web browser to navigate to the XmlFormGen.aspx file in that virtual directory.
  3. To load the included test form type in Test.xml and click the Load Form button.
  4. To create a new form type in the name of the form and add a .xml extension. Then click on the New Form button.
  5. 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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值