Click here to Skip to main content
16,016,501 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
I'm creating 2 pages login and signup wherein at the signup page consists of radiobuttonlist having values admin,student and teacher. Now after the user selects any of the 3 options, the page is redirected a login.aspx page, where the user has to enter the id and password. After it's authentication on login page, I want the user to be redirected to different pages according to the selection made on radiobutton in signup page. For eg. on selecting admin, I want the user to be redirected on page abc.aspx, while if the selection is student, the it should be redirected to page efg.aspx. please help
Posted

One of the way is to use a Login Control and redirect using DestinationUrl property to respective pages according to their roles.

Incase ,using Textbox and button controls, On Button Click event use Response.Redirect as per the DropdownList selection

Simple reference
http://weblogs.asp.net/anasghanem/archive/2008/04/12/redirecting-the-users-to-different-pages-based-on-there-roles.aspx[^]

http://stackoverflow.com/questions/5697586/how-do-i-redirect-to-a-page-after-successful-login[^]
 
Share this answer
 
v2
Comments
Member 10523130 14-Jan-14 10:10am    
But I am not using login control.Is there any other way?
JoCodes 14-Jan-14 10:24am    
yes , as given in the solution just use Response.Redirect on condition checking the dropdown selected values
Member 10523130 14-Jan-14 10:35am    
Using Response.Redirect i will be redirected..But have to redirect to welcome admin or teacher or student page after login.And I am using radio button list on Sign up page.How i can check that value at the time of login? according to that user will be redirected. please help
JoCodes 14-Jan-14 11:27am    
something like if(radioButtonList.SelectedValue=="somevalue1")
{
Response.Redirect("SomePage.aspx");
}
else if (radioButtonList.SelectedValue=="someothervalue1")
{
Response.Redirect("otherPage.aspx");
}
One very simple logic, let me explain.
  • You are at Sign Up Page.
  • You selected some option from RadioButtonList, you store that value in Session and redirected to Login Page.
  • You run your logic on Login Page to authenticate the user.
  • Now, if user is authenticated, check whether Session for that option exists or not.
  • If exists, get the value and redirect to the Page you want according to the option.
 
Share this answer
 
Comments
Member 10523130 14-Jan-14 10:30am    
How to store value in session? I have written following code in signup page
Session["type"]=typeButtonList1.SelectedValue;

and i have written foll code in login page
cmd = new SqlCommand("select username,password,ltype from login where username='" + txtusr.Text +"' and password='"+txtpass.Text+"'" , con);
dr = cmd.ExecuteReader();
if (dr.Read())
{

if (Session["type"] == "Admin")
{
Response.Redirect("welcomeadn.aspx");
}
}
But it is not working.please help
Have you debugged the code? Please debug and see if it going inside the if clause or not.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900