views:

66

answers:

3

when I write

Response.Redirect("Default2.aspx?Name=" + TextBox1.Text);

then

string input = Request.QueryString["Name"];

if I write yahoo+music in textbox

the input will be yahoo music why ? and how can I keep the '+' ?

+5  A: 

+ is the encoding for space in query strings. To encode + you need to use %2b.

Try UrlEncode which should handle this for you.

Mark Byers
+1  A: 

A plus in the URL means a space. You should URL encode the value that you put in the URL:

Response.Redirect("Default2.aspx?Name=" + Server.UrlEncode(TextBox1.Text));
Guffa
A: 

Hi, I've another way - although a little bit 'tricky' - to reach your goal by passing '+'(or any other special character) in query string

when you pass the query string you write like this:

Response.Redirect("Default.aspx?Name="+TextBox1.Text.Replace("+","_"));

then it will pass Default.aspx?Name=Yahoo_Music

and to request it, just replace again

string input = Request.QueryString["Name"].Replace("_","+");

input will be: Yahoo+Music.

although this way a little bit tricky but sometimes this way very helpful to pass special character in query string.

Thanks

Christofel