Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have "APM 23 X 23 # 1" record in my gridview. I clicked this record, passed this value to another form by using:

Initial form:
C#
e.Row.Attributes.Add("onclick", "javascript:window.location.href ='AutoPMPage.aspx?ID=" + e.Row.Cells[0].Text + "';");


Other form:
string Id = HttpContext.Current.Request.QueryString["id"];



But i cannot get full value from string Id. I only get "APM 23 X 23". "# 1" is missing.

Anyone know why?

Thanks!
Posted

Hi,

I think you may have some Url scan deployed at you machine.

easy solution is to replace your # with "[35]" and then reverse it at server.
 
Share this answer
 
1.
C#
string Id = HttpContext.Current.Request.QueryString["id"];

string Id = HttpContext.Current.Request.QueryString["ID"];//upper id

2.Weather or not your server can get the parameter of the client.



I guess,your url is wrong.
I want to know the routes of the .aspx and the .cs
 
Share this answer
 
v3
There are some characters that get encoded when put in URL. Instead of replacing them in Code you should think about putting a
C#
Server.UrlEncode(string);

before putting the data in query strings. and after retrieving do a
C#
Server.UrlDecode(string);

before using it.
 
Share this answer
 
Use:

C#
string encodedURL = System.Net.WebUtility.HtmlEncode(e.Row.Cells[0].Text.Trim());

e.Row.Attributes.Add("onclick", "javascript:window.location.href ='AutoPMPage.aspx?ID=" + encodedURL + "';");


And on AutoPMPage.aspx use:

C#
string Id = System.Net.WebUtility.HtmlDecode(HttpContext.Current.Request.QueryString["id"]);
 
Share this answer
 
Well if I were you I would use UrlEncoding and UrlDecoding for the pound key.
What I meant by this while passing your ID you should encode it and when you want to use it you should decode it to use it.

You should check the WebUtility Class[^].

Also here is an example link[^]that you can have a look at.

Good luck,
OI
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900