开发者

Javascript code in XsltListViewWebPart Give parsing error

开发者 https://www.devze.com 2023-02-28 03:40 出处:网络
I am working with XsltListViewWebPart, I add my custom xsl and it works good.This xsl contain an anchor tag like that

I am working with XsltListViewWebPart, I add my custom xsl and it works good.This xsl contain an anchor tag like that

 <a>
       <xsl:attribute name="title"><xsl:value-of select="@Title"/&g开发者_Go百科t;</xsl:attribute>
       <xsl:attribute name="onclick"><xsl:value-of select="@ID"/></xsl:attribute>
       <xsl:value-of select="@Title"/>
 </a>

When I am trying to complete my javascript code it gives me parsing error. Here is my code

 <a>
       <xsl:attribute name="title"><xsl:value-of select="@Title"/></xsl:attribute>
       <xsl:attribute name="onclick">OpenPopUpPage("/lists/news/dispform.aspx?isdlg=1&ID=<xsl:value-of select="@ID"/>");</xsl:attribute>
       <xsl:value-of select="@Title"/>
</a>

Can any one help me, Please?


With XML (and XSLT is XML) you need to escape any ampersand '&' as '&amp;' so try

 <a>
       <xsl:attribute name="title"><xsl:value-of select="@Title"/></xsl:attribute>
       <xsl:attribute name="onclick">OpenPopUpPage("/lists/news/dispform.aspx?isdlg=1&amp;ID=<xsl:value-of select="@ID"/>");</xsl:attribute>
       <xsl:value-of select="@Title"/>
</a>

or better yet use attribute value templates e.g.

<a title="{@Title}">
   onclick="OpenPopUpPage('/lists/news/dispform.aspx?isdlg=1&amp;ID={@ID}');">
   <xsl:value-of select="@Title"/>
</a>

as it makes the code shorter and easier to read.

0

精彩评论

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