I have a javascript variable that contains the contents of value, so when I try to use Server.UrlEncode(value), it doesn't let me pass the variable in.
Do you know how I can please overcome this?
I am using MVC3, so it's in a razor view.
Any help would be very much appreciated.
Thank you
function myMethod(myValue)
{
var value = myValue;
var url = "...?value=" + value;
...
}
young345
Member
201 Points
720 Posts
Extract query string value with a space in it
Nov 12, 2012 12:31 PM|LINK
Hi,
I'm trying to pass a value through a query string and this value has a space in it e.g. "...?value=Hello me"
When I am trying to extract the value, all I get is "Hello"
Please can someone advise me on how I can pass such a value through a query string and extract it, in its entirety.
Thank you very much
Prabakaran_r
Member
672 Points
111 Posts
Re: Extract query string value with a space in it
Nov 12, 2012 12:45 PM|LINK
Use Server.UrlEncode to encode the querystring.
URL = "abc.com?Value=" + Server.UrlEncode("Hello Me");
Mark the response which answers your question.
young345
Member
201 Points
720 Posts
Re: Extract query string value with a space in it
Nov 12, 2012 01:05 PM|LINK
Hi,
Thank you for your reply.
I have a javascript variable that contains the contents of value, so when I try to use Server.UrlEncode(value), it doesn't let me pass the variable in.
Do you know how I can please overcome this?
I am using MVC3, so it's in a razor view.
Any help would be very much appreciated.
Thank you
function myMethod(myValue) { var value = myValue; var url = "...?value=" + value; ... }ignatandrei
All-Star
134511 Points
21576 Posts
Moderator
MVP
Re: Extract query string value with a space in it
Nov 12, 2012 01:06 PM|LINK
How do you extract? Code, please.
young345
Member
201 Points
720 Posts
Re: Extract query string value with a space in it
Nov 12, 2012 01:09 PM|LINK
I've worked it out, I can use the built in function encodeURI(string)
Thanks for the help, its been useful