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.
The QueryString collection is used to retrieve the variable values in the HTTP query string. The HTTP query string is specified by the values following the question mark (?), like this: Link with a query string. The line above generates a variable named txt with the value "this is a query string test".
Query parameters are a defined set of parameters attached to the end of a url. They are extensions of the URL that are used to help define specific content or actions based on the data being passed. To append query params to the end of a URL, a '? ' Is added followed immediately by a query parameter.
The value of Request. QueryString(parameter) is an array of all of the values of parameter that occur in QUERY_STRING. You can determine the number of values of a parameter by calling Request. QueryString(parameter).
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With