I'm following a great article titled "Creating Dynamic ASP.NET Server Controls Using XML" at
http://www.devarticles.com/c/a/ASP.N...s-Using-XML/2/, but I'm running into strange problems when I attempt to re-produce the pages.
Basically, the ASP.NET server controls show up in the code, but they aren't being displayed on the page. The method I'm using involves XML/XSLT transformation on an ASP.NET page, but I've also tried just attaching the XSLT stylesheet to the XML doc to no avail.
So I've included the code that I'm using at the bottom of this post. If anyone can help me to figure out what I'm doing wrong, I'd appreciate it. Thanks.
XML DOC:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<test>
<survey name="Example Survey">
<question type="text" name="Title" required="yes"/>
<question type="text" name="Industry"/>
<question type="radio" name="Education">
<choice>High school</choice>
<choice>Some college</choice>
<choice>College</choice>
</question>
</survey>
</test>
XSLT DOC:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asp="remove">
<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="yes"/>
<xsl:template match="/">
<div id="content">
<table>
<xsl:for-each select="//question">
<tr>
<td valign="top"><xsl:value-of select="@name" />
<xsl:if test="@required = 'yes'">
<asp:RequiredFieldValidator ErrorMessage="RequiredField" runat="server" ControlToValidate="{@name}" />
</xsl:if>
</td>
<td>
<xsl:if test="@type='text'">
<asp:TextBox id="{@name}" runat="server" />
</xsl:if>
<xsl:if test="@type='radio'">
<asp:RadioButtonList id="{@name}" runat="server">
<xsl:for-each select="choice">
<asp:ListItem Value="{@value}"><xsl:value-of select="@value"/></asp:ListItem>
</xsl:for-each>
</asp:RadioButtonList>
</xsl:if>
</td>
</tr>
</xsl:for-each>
</table>
<asp:button id="submit" runat="server" Text="Submit" />
</div>
</xsl:template>
</xsl:stylesheet>
CODE OUTPUT:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head></head>
<body>
<form name="_ctl1" method="post" action="index.aspx?page=test" id="_ctl1">
<input type="hidden" name="__VIEWSTATE" value="dDw5OTQ1Mjc4NDc7dDw7bDxpPDE+O2k8Mz47PjtsPHQ8O2w8aTwxPjtpPDM+O2k8Nz47aTw5PjtpPDExPjs+O2w8dDxwPGw8aW5uZXJodG1sOz47bDxEb3VnbGFzIENvdW50eSwgS2Fuc2FzIC0gRmVlZGJhY2sgRm9ybSBURVNUOz4+Ozs+O3Q8cDxsPGhyZWY7PjtsPC9uZXdzaXRlL2RvY3MvY3NzL2dlY2tvLmNzczs+Pjs7Pjt0PHA8bDxjb250ZW50Oz47bDxcZTs+Pjs7Pjt0PHA8bDxjb250ZW50Oz47bDxcZTs+Pjs7Pjt0PHA8bDxjb250ZW50Oz47bDxGcmlkYXksIE9jdG9iZXIgMDYsIDIwMDY7Pj47Oz47Pj47dDw7bDxpPDE+Oz47bDx0PHA8cDxsPFRleHQ7PjtsPEZyaWRheSwgT2N0b2JlciAwNiwgMjAwNjs+Pjs+Ozs+Oz4+Oz4+Oz7sPS4LQzwPyQo7LC8Hr0V7L8jzTw==" />
<?xml version="1.0" encoding="iso-8859-1"?>
<div id="content" xmlns:asp="remove">
<table>
<tr>
<td valign="top">Title<asp:RequiredFieldValidator ErrorMessage="RequiredField" runat="server" ControlToValidate="Title" /></td>
<td>
<asp:TextBox id="Title" runat="server" />
</td>
</tr>
<tr>
<td valign="top">Industry</td>
<td>
<asp:TextBox id="Industry" runat="server" />
</td>
</tr>
<tr>
<td valign="top">Education</td>
<td>
<asp:RadioButtonList id="Education" runat="server">
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
<asp:ListItem Value=""></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</table>
<asp:button id="submit" runat="server" Text="Submit" />
</div>
</form>
</body>
</html>
DISPLAY OUTPUT (just text shows up):
Title
Industry
Education
KWilliams