Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

querystring values displays wrong

Status
Not open for further replies.

lin73

Programmer
Feb 17, 2006
110
SE
Hi

I try to write out a querystring value on my page, but the querystring contains a value like this....

mypage.aspx?K=l%F6v

and when I try to write that on my page with ..

Label1.Text = (Server.HtmlEncode(Request.QueryString("K")))

only 'lv' is written on the page when it really should have been löv (o with two dots over it). How can I get this to work?
 
Try using Server.URLEncode e.g.
Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Write("ö" & "<br>")
        Response.Write(Server.UrlEncode("ö") & "<br>")
        Response.Write(Server.UrlDecode("%c3%b6") & "<br>")
    End Sub


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Hi

Thanks for your reply, but I'm sorry to say that it doesn't work.... Any more ideas?
 
Hi

Yes I have, I tryed this...

Response.Write("UrlDecode = " & (Server.UrlDecode(Request.QueryString("N")) & ("<br>")))

On a adress like this...

and the result is "Njd" and not "Nöjd" as I want it to be..


I even tryed to do a replace("%F6","ö") but its like it doesn't exsits...
 
Your example give me this result on the page...

ö
%c3%b6
ö


So that part work, and then it should work with ..

Response.Write("UrlDecode = " & (Server.UrlDecode(Request.QueryString("N")) & ("<br>")))

But for some reason it doesn't. And I don't have a clue of why
 
Yes if I do a Response.Write(Server.UrlEncode("ö") & "<br>")
on my page, that character is written ok to the page. Buif I try that or the UrlDecode on my querystring value nothing shows....
 
I'm curious, why are you bothering to try and decode this at all? Before the value is placed in the Request.Querystring collection it should be decoded already. Have you tried just doing:
Label1.Text = Request.QueryString("K")

 
default4.aspx?N=N%F6jd
So if this is your querystring how is the encoded value possibly the same as mine? My example conatins "%c3%b6" and yours doesn't. I can't see how you possibly think these two are the same.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Hi Tarwn

Yes I have, but then the swedish character ö (%F6) isn't displayed in my page. The querystring contains name of persons, and I need to add that name to a database, so it need to be acurate.
 
Hi Mark

Sorry, I was so into that the ö should be a %F6 that I missed your whole point. You are absolutly correct and everything works just as I wanted and you said.

Thank you very much for all help!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top