开发者

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">&lt;Control:Content runat="server" contenttype="&lt;xsl:value-of select="subnode/text()"/&gt;" /&gt;</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>&lt;Control:Content runat="server" contenttype="</xsl:text>
  <xsl:value-of select="/subnode"/>
  <xsl:text>" /&gt;</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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜