I want to go to a different URL and pass a parameter as a query string. This value contains an ampersand. I can use Response.Redirect to do this.
Response.Redirect("http://www.mysite.com/?Value=" + Server.UrlEncode("This & That"))
However, I prefer to use the PostBackUrl property of the LinkButton control to do this because I want to pass extra information in addition to the value in the URL. If I try
<asp:LinkButton id="ID" runat="server" PostBackUrl="http://www.mysite.com?Value=This+%26+That"/>
and click on the link in IE, then I see http://www.mysite.com?Value=This+%26+That as the new URL and can use Request.QueryString["Value"] to obtain the value. That works fine.
However, if I use Chrome or Firefox, then the new URL is http://www.mysite.com?Value=This+&+That, and I get "This " as the value instead of "This & That". It appears that different JavaScript is generated in IE and other browsers on the page containing the LinkButton. What can I do to get around the problem? Why the difference between IE and other browsers?
If I use the NavigateUrl property of a HyperLink control instead, then I get the correct URL in all the browsers that I tried.