Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 5th, 2009, 12:56 AM
Authorized User
 
Join Date: Mar 2005
Location: Bangalore, Karnataka, India.
Posts: 36
Thanks: 2
Thanked 1 Time in 1 Post
Default Junk Characters in IE 7 + ASP.NET 2.0 Application

Hello,
I have a problem where the characters like "VIAÇÃO COMETA" comes as junk in the text box. This does not happen IE 6. Where as this happend in IE 7. Let me explain the scenario properly.
1. I have a parent page where in I get this value and set to a text box. (This comes perfectly all right).
2. I have to open a popup page which is basically a search page and the text becomes search criteria. Hence I am passing this as querystring.
var customerName = document.getElementById("txtCustomerName").value;//Read this into variable
var url="SampleSiteSearch.aspx?SCREENTYPE=POPUP&CUSTOM ERNAME="+customerName;//Pass QueryString.
I have given Alert to check this and it comes fine.
3. In the popup I am reading this value as below.
txtCustomerName.Text = Server.UrlEncode(Request.QueryString["CUSTOMERNAME"].ToString());
Here the junk character comes. Hence the popup shows junk characters and my search does not work.
I have tried giving URLDecode/HTMLdecode but no result.Can any one help me in this.
 
Old May 5th, 2009, 11:54 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I'm not sure I understand what you are attempting to accomplish.

If it is your intention to URL-encode the string, you should be doing that before passing it on the querystring. URL-encoding a string that is already in a URL doesn't really make sense.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old May 6th, 2009, 03:00 AM
Authorized User
 
Join Date: Mar 2005
Location: Bangalore, Karnataka, India.
Posts: 36
Thanks: 2
Thanked 1 Time in 1 Post
Default

Hello,
Yes this Decoding is not applicable. Also please note that I am using Javascript to Form the URL and then Use window.open method to open.

But when am trying to read the Querystring Value it returns me as Junk Characters. In some systems it is working in some systems it does not work. Not sure if IE / some setting of IE could be the reason.
 
Old May 6th, 2009, 11:37 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
Originally Posted by abinashpatra View Post
Hello,


But when am trying to read the Querystring Value it returns me as Junk Characters.
Yes, obviously. That's because you are calling the Server.UrlEncode method, which replaces non-alphanumeric characters with URL-encoded characters.

The point that I was trying to make before is that it makes no sense to Url-encode a value you are getting off the querystring. In other words, why are you even calling Server.UrlEncode?
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old May 6th, 2009, 12:21 PM
Authorized User
 
Join Date: Mar 2005
Location: Bangalore, Karnataka, India.
Posts: 36
Thanks: 2
Thanked 1 Time in 1 Post
Default

Hello,
Perhaps I didnt clarify you properly. Am not doing URLdecode. I am simply reading the query string. Request.QueryString["CUSTOMERNAME"].ToString()

I had tried URLDecode to check if this helps. Actually my code does not have this still it returns me junk characters.
 
Old May 7th, 2009, 01:27 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Okay, you're not following me at all here.

From your original post, you said you were doing the following:

txtCustomerName.Text = Server.UrlEncode(Request.QueryString["CUSTOMERNAME"].ToString());

When you call Server.UrlEncode on a string such as "VIAÇÃO COMETA", you get the following:

VIA%ef%bf%bd%ef%bf%bdO+COMETA (in IE 8)

VIA%c3%87%c3%83O+COMETA (in FF3)

The ASCII characters are not altered. However, the non-ASCII characters (Ç and Ã) are altered. The [space] is also changed to a +.

What I am trying to tell you is that there is no need to call Server.UrlEncode here. It makes no sense, since you are reading the string OUT of the querystring. The Server.UrlEncode method is only meant to be used when you are putting the string INTO the querystring.

I don't know how to explain it any more plainly than this. Maybe someone else could jump in at this point and try to make it clearer.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old May 7th, 2009, 01:44 AM
Authorized User
 
Join Date: Mar 2005
Location: Bangalore, Karnataka, India.
Posts: 36
Thanks: 2
Thanked 1 Time in 1 Post
Default

Dear Lee,
There is still confusion in this. Perhaps this is with the code I have given in query( Original Query). As I had explained in the last reply I am actually not using URLDecode in the code. It's that I was trying putting the URLDecode and test and I pasted that code in the original query. Hence below is the correct code which is present in my solution and this below code itself returning the Junk Characters like "VIA??O COMETA"

txtCustomerName.Text =Request.QueryString["CUSTOMERNAME"].ToString();




Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP and ASP.NET mixture for protecting application BananaJim ASP.NET 2.0 Professional 0 December 6th, 2006 02:19 PM
SQL vs ASP.NET..escape characters haunting Quick209 ASP.NET 2.0 Basics 0 May 17th, 2006 03:26 PM
Enabling Arabic characters in ASP.NET-Oracle Appli abinashpatra ASP.NET 1.0 and 1.1 Basics 0 November 8th, 2005 12:21 AM
Convert ASP web application to ASP.NET Steve777 ASP.NET 1.0 and 1.1 Basics 3 June 2nd, 2005 07:26 AM
Creating ASP.NET Application in Visual Studio.NET Maxood ASP.NET 1.0 and 1.1 Basics 1 March 8th, 2004 01:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.