11

I think my tittle is inaccurate.

When a user clicks on a button I need it to do this:

Response.Redirect("Login.aspx?userid=XX");

How can I get the "userid?" from ?userid. so I can show a page. Like doing "?page=3" and show page 3, in the same page or something.

The Button code is: (just if you need it)

protected void LoginButton_Click(object sender, EventArgs e)
{
    Response.Redirect("Login.aspx");
}

Thanks a lot! Sorry if I didn't ask it good, and sorry for the bad English.

2 Answers 2

28

Use Request.QueryString:

First Page Sends them another page with their user id in the url:

Response.Redirect("AfterLogIn.aspx?userid=23");

You then Read it using the below code:

var g = Request.QueryString["userid"] //this value should be 23 now

You could then use this g variable to do any amount of custom things (Hide panels, show controls, etc.)

Sign up to request clarification or add additional context in comments.

Comments

3

You can do something like this

protected void LoginButton_Click(object sender, EventArgs e)
        {
                var id = // whatever userid
                Response.Redirect("Login.aspx?userid="+ id);
        }

and in the pageload of Login page

    var userid = Request.QueryString["userid"];

ASP.NET State Management will explain further.

Hope this helps

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.