Navigate a URL with Query string values on click of hyperlink

karthik k picture karthik k · Jun 2, 2011 · Viewed 11k times · Source

I have a control with 'email' and 'password' textboxes and a 'autoLogin' checkbox. All are web form controls (not html controls). And there is a 'Login' hyperlink. When I click on heperlink, I want to move to other page using NavigateUrl property like below:

NavigateUrl="~/DoLogin.aspx?email={0}&pwd={1}&autoLogin={3}"

how to pass and how to get the query string?

Thanks in Advance...

Answer

Vir picture Vir · Jun 2, 2011
private void btnSubmit_Click(object sender, System.EventArgs e)
{
Response.Redirect("Webform2.aspx?Email=" +
this.txtemail.Text + "&Pwd=" +
txtPassword.Text);
} 

now for the next page(Webform2.aspx) go there and in page load event write this code

private void Page_Load(object sender, System.EventArgs e)
{
string Email = Request.QueryString["Email"];
 string password = Request.QueryString["Pwd"];
} 

You can use this one also

private void Page_Load(object sender, System.EventArgs e)
{
 string Email = Request.QueryString[0];
 string password = Request.QueryString[1];
}

place this values where You Want