views:

114

answers:

2

How do I convert guid to string in javascript. I am getting guid from the querystring, and m not able to process it as is. I have tried the following ways to do it but it doesnt seem to work.

var guid = {<%=Request.QueryString["Guid"]%>}.toString();
var guid = <%=Request.QueryString["Guid"]%>.toString();
var guid = (string)<%=Request.QueryString["Guid"]%>;
var guid = (string){<%=Request.QueryString["Guid"]%>};

Any suggestions?

A: 

Have you tried just:

var guid = {<%=Request.QueryString["Guid"]%>}
Tony Abrams
Nope, doesnt seem to work.
Hna0002
What do you mean by doesn't work? Are there any error messages?
Tony Abrams
In debug mode it was showing without any quotes or anything as if its an int or something. '<%=Request.QueryString["Guid"].ToString()%>' worked. Thank you!
Hna0002
+2  A: 

Try quoting the string, this should work...

var guid = '<%=Request.QueryString["Guid"]%>';
Quintin Robinson
Nope, doesnt seem to work.
Hna0002
What is the output?.. you could try: `var guid = '<%=Request.QueryString["Guid"].ToString()%>';` but it shouldn't make a difference.
Quintin Robinson
That works! Thanks.
Hna0002