Displaying a C# control through XSLT
Is there a way to display a C# control through XSLT?
I'm trying a lot to handle this but am not able to pass the values to the control.
Below is the sample which am trying to render it out..
<xsl:text disable-output-escaping="yes"><Control:Content runat="server" contenttype="<xsl:value-of select="subnode/text()"/>" /></xsl:text>
Here control should generate as shown: For the param "contenttype" value should pass dynamically...
<Control:Content runat="serv开发者_运维百科er" contenttype="ABC123" />
Please help me.
You don't need (and it is always a good idea to avoid using) DOE for this.
Here is a neat solution, just using <xsl:output method="text">
:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/*">
<xsl:text><Control:Content runat="server" contenttype="</xsl:text>
<xsl:value-of select="/subnode"/>
<xsl:text>" /></xsl:text>
</xsl:template>
</xsl:stylesheet>
when this transformation is applied on this XML document:
<subnode>html</subnode>
the wanted, correct output is produced:
<Control:Content runat="server" contenttype="html" />
We're using this technique at work, however, we convert the control to xml first then we use xslt to render it in the page.
精彩评论