B
bic
Hi,
I have an sample code for an asp.net xml control to display xsl data as
follows. Can someone show how to modify both xsl code and asp.net code for
using this xml's name element to populate an asp.net dropdown. Also with a
dropdown item selected I want all elements of that item display on the page.
Thanks in advance.
---------------sample1.xml-------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="sample1.xslt"?>
<Employees>
<Employee>
<EmployeeId>001</EmployeeId>
<Name>Stuart</Name>
<Age>28</Age>
</Employee>
</Employees>
---------------sample1.xslt-------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<b>Employee ID: </b><xsl:value-of select="Employees/Employee/EmployeeId"
/><br/>
<b>Name of Employee : </b><xsl:value-of select="Employees/Employee/Name"
/><br/>
<b>Age:</b><xsl:value-of select="Employees/Employee/Age" /><br/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
---------asp.net----------
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("people.xml"));
XslTransform trans = new XslTransform();
trans.Load(Server.MapPath("peopletable.xsl"));
xml1.Document = doc;
xml1.Transform = trans;
}
</script>
<head id="Head1" runat="server">
<title>Xml Class Example</title>
</head>
<body>
<h3>Xml Example</h3>
<form id="form1" runat="server">
<asp:Xml id="xml1" runat="server" />
<%--<aspropDownList ID="DropDownList1" runat="server"
DataTextField="FirstName" DataValueField="Street">
</aspropDownList>
--%> </form>
</body>
</html>
I have an sample code for an asp.net xml control to display xsl data as
follows. Can someone show how to modify both xsl code and asp.net code for
using this xml's name element to populate an asp.net dropdown. Also with a
dropdown item selected I want all elements of that item display on the page.
Thanks in advance.
---------------sample1.xml-------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="sample1.xslt"?>
<Employees>
<Employee>
<EmployeeId>001</EmployeeId>
<Name>Stuart</Name>
<Age>28</Age>
</Employee>
</Employees>
---------------sample1.xslt-------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<b>Employee ID: </b><xsl:value-of select="Employees/Employee/EmployeeId"
/><br/>
<b>Name of Employee : </b><xsl:value-of select="Employees/Employee/Name"
/><br/>
<b>Age:</b><xsl:value-of select="Employees/Employee/Age" /><br/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
---------asp.net----------
<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("people.xml"));
XslTransform trans = new XslTransform();
trans.Load(Server.MapPath("peopletable.xsl"));
xml1.Document = doc;
xml1.Transform = trans;
}
</script>
<head id="Head1" runat="server">
<title>Xml Class Example</title>
</head>
<body>
<h3>Xml Example</h3>
<form id="form1" runat="server">
<asp:Xml id="xml1" runat="server" />
<%--<aspropDownList ID="DropDownList1" runat="server"
DataTextField="FirstName" DataValueField="Street">
</aspropDownList>
--%> </form>
</body>
</html>