Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing a web application, I need to pass values from one page to another page, so i have used QueryString and wrote code as below:
Response.Redirect("WebForm2.aspx?name=sunny")

When I am getting values from querystring collection by write code
string str=Request.QueryString["name"];

I get null value in str
can anyone suggest me something so that i can get ride of this problem
Posted
Updated 17-Dec-10 22:53pm
v3

1 solution

That is a little odd - double check you are running with the right code, and that the code is in the WebForm2.aspx file. I tried it here in my form load:
C#
int c = Request.QueryString.Count;
TextBox1.Text = "Query: " + c;
if (c > 0)
    {
    TextBox1.Text += "\n" + Request.QueryString["hello"];
    }
With a button:
C#
protected void Button1_Click(object sender, EventArgs e)
    {
    Response.Redirect("default.aspx?hello=\"Hi There\"&theEnd=Terminus");
    }
It worked as expected.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900