all groups > dotnet xml > may 2006 >
You're in the

dotnet xml

group:

how to pass parameters to xsl from my aspx file


how to pass parameters to xsl from my aspx file Wang Xiaoning
5/15/2006 2:42:24 PM
dotnet xml: I have an customerdetail.xsl sheet
----------------------------------------------------------


<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="customer_number"></xsl:param>

<xsl:template match="customerlist">
<html>
<body>
<table border="1" frame="box">
<xsl:for-each
select="mag_customer[@customer_number=$customer_number]">
<tr>
<TH>Customer</TH>
<td><xsl:value-of select="@customer"/></td>
</tr>
<tr>
<TH>Address</TH>
<td><xsl:value-of select="@address"/></td>
</tr>
<tr>
<TH>Telephone</TH>
<td><xsl:value-of select="@telephone"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

my customerdetail.aspx code is like this
---------------------------------------

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="CustomerDetails.aspx.vb" Inherits="CustomerDetails" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
&nbsp;</div>
<asp:Xml ID="Xml1" runat="server"
DocumentSource="~/App_Data/customerlist.xml"
TransformSource="~/App_Data/customerdetail.xsl"></asp:Xml>
</form>
</body>
</html>


i also have customer.aspx file(witch will redirect to
customerdetails.aspx as long as user selected a customer number) and
inside i have the "customer_number" paramaters,my question is from
customer.aspx how do i pass the customer_number value to
cusomerdetails.aspx and further to the customerdetail.xsl?

thanks
Re: how to pass parameters to xsl from my aspx file Oleg Tkachenko [MVP]
5/16/2006 12:00:00 AM
[quoted text, click to view]

You can pass parameters from aspx to aspx using various methods - from
Session to HTTP Request parameters. And you can pass parameters to XSLT
using TransformArgumentList property of the XML control.

--
Oleg Tkachenko [XML MVP, MCAD]
Re: how to pass parameters to xsl from my aspx file Wang Xiaoning
5/16/2006 11:13:42 AM
my customerdetails.aspx has this code

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="CustomerDetails.aspx.vb" Inherits="CustomerDetails" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div></div>
<asp:Xml ID="Xml1" runat="server"
DocumentSource="~/App_Data/customerlist.xml"
TransformSource="~/App_Data/customerdetail.xsl"></asp:Xml>
&nbsp; &nbsp;
</form>

</body>
</html>


if i want to pass customer_number A00010 xsl, where do i put this code,
in page_load() ?

Dim xslArg As New System.Xml.Xsl.XsltArgumentList()
xslArg.AddParam("customer_number", "", "A00010")
Re: how to pass parameters to xsl from my aspx file Wang Xiaoning
5/16/2006 11:21:28 AM
i fond i forgot

Xml1.TransformArgumentList

after i have this, it works, thanks for the support.
AddThis Social Bookmark Button