I am upgrading a legacy application and it uses the annoying practice of using Javascript window.open() to open popup windows in order to set values. I’m having a problem passing querystring variables to that popup window, since the url is built server side.
Example
JS:
function popupwindow(vLink) {
window.open(vLink, 'Detail','width=600px,height=545px,status=yes,help=no,scrollbars=yes,resizable=yes,top=350');
}
XML
<asp:Label ID="lblOpener" runat="server" Text="_"></asp:Label>
Server Side
int ditem = 123;
string dcode = "ABC";
string vLink = string.Format("detail.aspx?item={0}&code={1}", ditem, dcode);
lblOpener.Attributes.Add("onclick", "popupwindow('" & vLink & "');");
When the label is clicked I am expecting the popup to open with the querystring:
http://detail.aspx?item=123&code=ABC
Instead, I get something like this:
http://detail.aspx?item=123&%3bcode=ABC
How can I prevent this from happening?
You could try encoding using a JavaScriptSerializer: