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 '+' ?
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 '+' ?
+
is the encoding for space in query strings. To encode +
you need to use %2b
.
Try UrlEncode
which should handle this for you.
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));
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