Code :
string url = "http://www.google.com";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "UrlSocialDefinitivo", "var UrlSocialDefinitivo=" + Server.UrlEncode(url) + ";", true);
but I get (on browser console) : SyntaxError: identifier starts immediately after numeric literal.
In fact it registers UrlSocialDefinitivo=http%3a%2f%2fwww.google.it;
Where am I wrong? How can I resolve this trouble?
It miss the quotes around the string :
That will produces :
Note that I’m not sure you have to keep the
Server.UrlEncorecall. It depends on the format you are expecting actually.