Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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:
  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 27-Dec-12 21:27pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

1.
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
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

There are some characters that get encoded when put in URL. Instead of replacing them in Code you should think about putting a
Server.UrlEncode(string);
before putting the data in query strings. and after retrieving do a
Server.UrlDecode(string);
before using it.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Use:
 
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:
 
string Id = System.Net.WebUtility.HtmlDecode(HttpContext.Current.Request.QueryString["id"]);
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 337
1 DamithSL 310
2 OriginalGriff 220
3 Zoltán Zörgő 149
4 Peter Leow 115
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 5,044
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100