1

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...

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
karthik k
  • 3,751
  • 15
  • 54
  • 68

4 Answers4

3
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

Vir
  • 1,294
  • 1
  • 13
  • 23
0

The easiest way would be to not use a hyperlink but a button (or link button) and make a postback and then use, Response.Redirect("Url") or event better, process the login directly. Otherwize you have to collect your data using javascript.

Magnus
  • 45,362
  • 8
  • 80
  • 118
0

On Login Click write this code

Response.Redirect("~/DoLogin.aspx?email=" + txtEmail.txt + "&pwd=" + txtPwd.text)
Deepesh
  • 5,346
  • 6
  • 30
  • 45
  • 1
    What if the password includes an ampersand? Server.UrlEncode() needs to be put around both strings. Although I would recommend doing this anyway for security reasons... – Curtis Jun 02 '11 at 10:24
0

I'm assuming your doing this because your DoLogin page has some login code in the Page_Load?

I really wouldn't recommend passing username/password credentials in a URL.

Like @Magnus has stated, it would be better to change the Hyperlink to a LinkButton and put your code in there.

Curtis
  • 101,612
  • 66
  • 270
  • 352