Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 6th, 2006, 01:42 PM
Banned
Points: 1,561, Level: 16
Points: 1,561, Level: 16 Points: 1,561, Level: 16 Points: 1,561, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating Dynamic ASP.NET Server Controls Using XML

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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problems in creating dynamic controls merinmathew ASP.NET 1.0 and 1.1 Basics 0 January 12th, 2006 01:06 AM
Dynamic generation of asp.net server controls shashi1312 Classic ASP XML 1 August 2nd, 2005 04:52 AM
Creating Dynamic Forms with ASP.NET saturdave ASP.NET 1.0 and 1.1 Basics 5 November 23rd, 2004 06:10 PM
Dynamic generation of controls in ASP.NET Maxood ASP.NET 1.0 and 1.1 Basics 2 March 8th, 2004 07:29 PM



All times are GMT -4. The time now is 12:51 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.