Esha
Esha

Reputation: 389

Redirecting to page from radio button selection

I'm creating multiple pages wherein at the first page consists of 2 radiobuttonlist having values admin and customer. Now after the user selects any of the two options, the page is redirected a login.aspx page, where the user has to enter the id and password. After it's authentication, I want the user to be redirected to different pages according to the selection made on radiobutton.

For eg. on selecting admin, I want the user to be redirected on page abc.aspx, while if the selection is customer, the it should be redirected to page efg.aspx.

Is it possible?

Upvotes: 0

Views: 1217

Answers (3)

Matías Fidemraizer
Matías Fidemraizer

Reputation: 64943

Yes, of course. This is something that you can achieve storing the radio button selection into some cookie for later send it with the authentication HTTP request.

Once user is authenticated, just read the whole cookie and redirect to the desired page.

For example:

string virtualPath = null;

switch(HttpContext.Current.Request.Cookies["UserRole"].Value)
{
      case "Admin":
           virtualPath = "~/admin.aspx";
           break;

      case "RegularUser"
           virtualPath = "~/user.aspx";
           break;
}

HttpContext.Current.Response.Redirect(virtualPath);

Upvotes: 2

levelnis
levelnis

Reputation: 7705

You could append something onto the querystring from the radio button selection before you do the redirect to the login page. The login page could then redirect based on the value of the querystring parameter.

Upvotes: 0

Kami
Kami

Reputation: 19437

Have you tried saving the result of the postback from the radiobuttonlist to a session variable, when they login, use the value from the session variable to direct them as required.

You can also put the value into a hidden field on the login page, if the session is not an option.

Upvotes: 0

Related Questions