我目前有以下 XSLT 文件
<xsl:template match="/">
<html>
<head>
</head>
<body>
<input type="text" id="txtSearch"/>
<input type="submit" name="btnSearch" value="Search" onclick="" />
<br />
<br />
<!-- Call to the procedure/function -->
<xsl:apply-templates select="CommercialClients">
</xsl:apply-templates>
</body>
</html>
</xsl:template>
<!-- Procedure/function -->
<!-- Loop through each AClient and retrieve CompanyName-->
<xsl:template match="CommercialClients">
<xsl:for-each select="AClient[starts-with(CompanyName,'L')]">
<xsl:sort select="CompanyName" order="ascending"/>
<xsl:value-of select="CompanyName"/>
<br />
</xsl:for-each>
</xsl:template>
而且我还有一个 XML 文档,它是这样的:
<CommercialClients>
<AClient>
<ClientNo>1813</ClientNo><CompanyName>K Plastics</CompanyName><FullAddress>
<Address>Cleveragh Industrial Estate </Address>
<Town>SLIGO</Town>
<Country>IRELAND</Country>
<PostCode>00353 7166</PostCode>
</FullAddress><TelephoneNo/>
</AClient>
我的问题:我想使用我制作的按钮,以便当用户单击该按钮时,它会从文本框中获取用户的输入并过滤要显示的数据。
因此,如果用户输入文本框“L”,它只会显示以字母“L”开头的公司。目前,仅显示带有“L”的公司是硬编码的,我不确定如何使其成为用户定义的。
有什么帮助或想法吗?这是 ASPX 文件,但我不知道如何使用所有这些来编辑过滤器!
//from the request object get the value of the filter
string AFilter = Request.QueryString["txtFilter"];
//if there is no filter
if (AFilter == null)
{
//make the filter a blank string (a null value will crash the program)
AFilter = "";
}
//create an instance of the XML Conduit class passing the name of the xml file to the constructor
MyClassLibrary.clsXMLConduit MyXMLConduit = new MyClassLibrary.clsXMLConduit("commercial.xml");
//add a parameter to filter the data on company name
MyXMLConduit.AddParameter("CompanyFilter", AFilter);
//perform the transformation using the xslt file commercial.xslt
MyXMLConduit.Execute("commercial.xslt");
//set the character set encoding for the output stream
Response.Charset = "UTF-8";
//output the transformed document to the requesting browser
Response.Write(MyXMLConduit.TransformedOutput);