jay-are
asked on
request querystring problems with symbols?
Hello Experts
I'm trying to get a string passed through a url. Here is the code I currently use:
Public Property myStr() As String
Get
myStr = CStr(Request.QueryString(" ctrlnum"))
End Get
Set(ByVal Value As String)
myStr = Value
End Set
End Property
This works fine for most strings. For some reason though when a value like "J&J INC" is passed it ignores the '&' symbol and just stops so my value ends up being "J" and that's it. How do I fix this so I get the full querystring that is passed? I know the program that is sending the query is right because I can see the actual "J&J INC" in my URL. How do I fix this in vb?
I'm trying to get a string passed through a url. Here is the code I currently use:
Public Property myStr() As String
Get
myStr = CStr(Request.QueryString("
End Get
Set(ByVal Value As String)
myStr = Value
End Set
End Property
This works fine for most strings. For some reason though when a value like "J&J INC" is passed it ignores the '&' symbol and just stops so my value ends up being "J" and that's it. How do I fix this so I get the full querystring that is passed? I know the program that is sending the query is right because I can see the actual "J&J INC" in my URL. How do I fix this in vb?
something like this
string url="/Home.aspx?ctrlnum=" + Server.UrlEncode(values));
string url="/Home.aspx?ctrlnum=" + Server.UrlEncode(values));
ASKER
You want me to change the actual link instead of fixing my querystring?
The link that sends me the value is a javascript. It passes it to the URL properly, its just that my VB code doesn't query it correctly.
The link that sends me the value is a javascript. It passes it to the URL properly, its just that my VB code doesn't query it correctly.
in that case i can only suggest
use Request.RawUrl
with substring to get the desired part of url
hope that helps
use Request.RawUrl
with substring to get the desired part of url
hope that helps
ASKER
Ok that pulls most of the URL. Is there a way to trim that string down and grab just what's after "?ctrlnum=" ??
Then remove the space characters (%20)?
Then remove the space characters (%20)?
post your url
ASKER
/arparentnotes/webform1.as px?ctrlnum =A&R%20BOD Y%20SHOP
That's one of the few that have the '&' symbol. Most just have spaces in their names.
That's one of the few that have the '&' symbol. Most just have spaces in their names.
string s = Request.RawUrl
int i = s.LastIndexOf("=")
string param = s.Substring(i+1, s.Length - i-1)
param = param.Replace("%20", "")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked perfectly. Thanks!
Server.UrlEncode( QueryparamHere)