不用VS.Net生成Web项目时,如何在.aspx文件中添加引用?
大可山人 博客专家认证 2004-03-05 08:11:00 Apply XSLT Transformation by Using MSXML
Paste the following code in Notepad or another text editor, and then save the file as Msxml.xslt:<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://my_domain_name/my_namespace">
<msxsl:script language="VBScript" implements-prefix="user">
Function ConvertDate(nodeList)
ConvertDate = FormatDateTime( Left(nodeList(0).text, 10),1)
End Function
</msxsl:script>
<xsl:template match="/">
<xsl:value-of select="user:ConvertDate(data)"/>
</xsl:template>
</xsl:stylesheet>
Create a new ASP.NET Web Application project named DateTimeMSXml by using Visual C# .NET.
On the Project menu, click Add Reference.
On the COM tab, select Microsoft XML, v3.0. //这里怎么在aspx页面中添加引用?
Click Select, and then click OK .
Right-click the designer surface of WebForm1.aspx, and then click View Code to edit the WebForm1.aspx.cs class module.
Paste the following code in the Page_Load event:MSXML2.DOMDocument doc = new MSXML2.DOMDocumentClass();
doc.async = false;
doc.resolveExternals = false;
// Load XML document.
doc.load(this.MapPath("Q330602.xml"));
MSXML2.DOMDocument xsl = new MSXML2.DOMDocumentClass();
doc.async = false;
doc.resolveExternals = false;
// Load XSLT document.
xsl.load(this.MapPath("msxml.xslt"));
// Transform XML data.
string temp = doc.transformNode(xsl);
Response.Write(temp);
Save the changes to WebForm1.aspx.cs.
Make sure that the Q330602.xml and Msxml.xslt files are in the folder where the project is created.
On the Build menu, click Build Solution.
Start Internet Explorer and open the WebForm1.aspx file. To do this, specify the following URL, where IISServerName is the name of your IIS server: http://IISServerName/DateTimeXSLT/WebForm1.aspx
VS.Net生成太多的垃圾代码,如何直接在.aspx页面中添加COM引用?