Home arrow ASP.NET arrow Creating Dynamic ASP.NET Server Controls Using XML

Creating Dynamic ASP.NET Server Controls Using XML

A common way of using XML in ASP websites is to format dynamic information. In this article Eric shows us how to create a survey application using ASP.Net and XML.

Author Info:
By: Wrox Team
Rating: 5 stars5 stars5 stars5 stars5 stars / 207
December 12, 2002
  1. · Creating Dynamic ASP.NET Server Controls Using XML
  2. · Generation of Server Controls From Text
  3. · Custom Survey System Example
  4. · XML Namespaces
  5. · Conclusion

print this article

Creating Dynamic ASP.NET Server Controls Using XML
(Page 1 of 5 )

ASP.NET has made website development easier with its array of server controls that expose sophisticated behaviors, such as data binding and validation, along with a rich programming model that can directly interact with these server controls. XML and XSLT technology has also made website development better by allowing the separation of content and presentation.

A common way of using XML in ASP websites is to format dynamic information, such as query results, into a destination format (HTML or PDF). However, if you wanted to allow the user to interact with the returned information via a form, you had to use a mix of traditional ASP techniques, such as iterating over the Request.Form collection, and outputting HTML form elements. This approach works with .NET, but you lose the powerful features of ASP.NET server controls, such as data binding, state management, input validation, and the rich event model.

If you have used strongly typed datasets in .NET, you have seen the power of combining XML with the .NET platform. A strongly typed dataset consists of a number of classes whose code is generated by an XML document that defines what the code should do. The xsd.exe tool then generates the actual code based upon the requirements as defined in the XML document. XML then becomes a tool for meta-programming (or generative programming), which is the process of using code to generate code. The goal here is the same - to show how to use XML with an XSLT to generate ASP.NET code, specifically server controls. Utilizing intrinsic ASP.NET parsing methods with the XSLT output, you will have another meta-programming tool to make website development faster, easier, and better.

To illustrate this technique, we will create an example application - a custom survey system, where an XML document defines the structure of a web survey. The XSLT defines the layout and behavior of the web page, as well as postback behavior, allowing for a completely dynamic system, which, by using ASP.NET cross browser support, will work on all browsers. This dynamic nature could be used to allow users or content maintainers to define surveys by creating new XML documents, develop branching surveys based on a previous input, and more, all without the need to manually write any new code. All these feature extensions can be accomplished by editing the XSLT that generates the ASP.NET code.

By allowing non-programmers to create an XML document that will generate code, you can reduce the load on ASP.NET developers, but still leverage all of ASP.NET's power. In essence, you can have a system that allows users to specify what they want, and not need to know how to make it happen. This particular example will use a simple results storage system, as well as omitting some processes that would be needed in a robust system, as the purpose is not to present a complete system, but to illustrate a meta-programming technique.

The code and techniques described here require ASP.NET, Windows 2000 or XP, along with IIS. The code is written in C#, and assumes knowledge of ASP.NET, XML and XSLT.
blog comments powered by Disqus

- How Caching Means More Ca-ching, Part 2
- How Caching Means More Ca-ching, Part 1
- Reading a Delimited File Using ASP.Net and V...
- What is .Net and Where is ASP.NET?
- An Object Driven Interface with .Net
- Create Your Own Guestbook In ASP.NET
- HTTP File Download Without User Interaction ...
- Dynamically Using Methods in ASP.NET
- Changing the Page Size Interactively in a Da...
- XML Serialization in ASP.NET
- Using Objects in ASP.NET: Part 1/2
- IE Web Controls in VB.NET
- Class Frameworks in VB .NET
- Cryptographic Objects in C#: Part 1
- Sample Chapter: Pure ASP.Net

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials