Sample Application: XML Form Generator, Part 1: Generating an XML Form
page 1 of 1
Published: 14 Sep 2004
Unedited - Community Contributed
Abstract
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 Andrew Mooney
Feedback
Average Rating: 
Views (Total / Last 10 Days): 58578/ 54

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

Part 2: Capturing User Input
Part 3: Displaying the Results


User Comments

No comments posted yet.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-11-21 8:50:34 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search