I have pages with special characters in the title for proper typography, for example it says Exchange ‘07 Groups" with a proper apostrophe, not a single quote. The HTML entity for the apostrophe is ‘
So, I've found that if I set the page title from VB, the title displays just fine, but as soon as an update panel updates that HTML entity gets re-encoded and displays incorrectly as "Exchange ‘07 Groups"
So here's my code where I simply set the page title, then an update panel, and a button to update it...
<script runat="server">
Protected Sub Page_Load(...) Handles Me.Load
Page.Title = "Exchange ‘07 Groups"
End Sub
Protected Sub uxLnkDoClick(ByVal sender As Object, ByVal e As System.EventArgs)
uxLitLoaded.Text = "Loaded!"
End Sub
</script>
<!DOCTYPE html>
<html>
<head runat="server"></head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton runat="server" ID="uxLnkDo" OnClick="uxLnkDoClick" Text="Do Something" />
<asp:Literal runat="server" ID="uxLitLoaded" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="uxLnkDo" />
</Triggers>
</asp:UpdatePanel>
</form>
</body>
</html>
What can be done about this?
In your code to set the page title, wrap the text in Server.HtmlDecode:
Page.Title = Server.HtmlDecode("Exchange ‘07 Groups")
I had the same situation with the SM (service mark, as opposed to TM for trademark) which we did setting the page title with Page.Title = "My Company ℠";
. It reencoded it upon postback.
What we did is in the page head we statically added it
< title >My Company ℠< /title >
Worked like a charm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With