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 & 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 & Photo</asp:Hyperlink>
works
精彩评论