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 everyone,
i need to pass one city name to another page using query string.its like
'Coeur d 'Alene' but its considering only before single quote like 'Coeur d'
so please provide me solution soon.......
Posted 21-Jan-13 1:18am
Comments
digimanus at 21-Jan-13 7:23am
   
\'
SureshDasari1986 at 21-Jan-13 7:46am
   
its working here without decoding
public partial class Aspx_ZSamples_Default10 : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Default11.aspx?Value='Coeur d 'Alene'");
}
}
 

public partial class Aspx_ZSamples_Default11 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strValue = Request.QueryString["Value"].ToString();
string strValue1 = HttpUtility.HtmlDecode(Request.QueryString["Value"].ToString());
}
}
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You could consider using HttpUtility.UrlEncode[^]. This will help you escape quote symbol.
  Permalink  
Comments
Marcus Kramer at 21-Jan-13 9:55am
   
+5. The correct way to do this.
Abhinav S at 21-Jan-13 10:30am
   
Thank you Marcus.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

before adding any data to the querystring you should always do a Server.UrlEncode on that. after retrieving the data you should do Server.UrlDecode on query string to get the actual data out of it.
 
http://msdn.microsoft.com/en-us/library/ms525738(v=vs.90).aspx[^]
http://msdn.microsoft.com/en-us/library/6196h3wt.aspx[^]
  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 464
1 CHill60 415
2 OriginalGriff 345
3 PIEBALDconsult 245
4 BillWoodruff 183


Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 21 Jan 2013
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