开发者

How to get ASP.NET HyperLink control to encode ampersands in Text attribute?

I use the following control to output a HTML link:

<asp:HyperLink ID="hlEditDetails" runat="server" CssClass="arrow-forward" Text="Edit Details &amp; Photo" />

However, when it does, the markup is generated as:

<a id="ctl00_hlEditDetails" class="arrow-forward" href="/开发者_JS百科EventName/EditDetails.aspx?ID=1">Edit Details & Photo</a>

The unescaped ampersand is causing an error on the XHTML validator. Is there a way to make the HyperLink control generate the text correctly without writing out the HTML ourselves? The reason we're using the control in the first place is because the URL is dynamic. It's not a huge problem, but very annoying to see validation fail due to .net inflexibility, when the control should be making things easier.


<asp:HyperLink ID="hlEditDetails" runat="server" CssClass="arrow-forward">Edit Details &amp; Photo</asp:Hyperlink>

works

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜