开发者

Navigate a URL with Query string values on click of hyperlink

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. W开发者_Go百科hen 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...


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


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.


On Login Click write this code

Response.Redirect("~/DoLogin.aspx?email=" + txtEmail.txt + "&pwd=" + txtPwd.text)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜