Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am create NewUser Table, and Login Page.

I have Login page, in that login page 1)UserName(txtbox1),2)Password(txtbox2),3)UserType In DropDownList(Admin/Executive) & Login Button.

When I click Login Btn , it will check username,pass,usertyper( if I chooes "Admin")so as per DB (NewUser Tbl) and redirect the page in Admin(Folder)--->Home.aspx(Its Belog to Master Page), similar for Execute if i chooes "Executive" check username & pass and page redirect to Executive(Folder)--->Home.aspx other wise give invalid pass & username. plz solustion as per asp.net 4.0
Posted
Comments
Tejas Vaishnav 3-Oct-12 6:31am    
Have you tried something..

Hi,

You can write code as below.

C#
string usreType = DropDownList.SelectedItem.Value;

//Validate and authenticate user 
bool IsValidUser = //validate user form db with user name, password and user type
if(IsValidUser)
{
   switch(userType)
   {
     case : "Admin" //Redirect user to Admin folder
     break;
     case : "Executive " //Redirect user to Executive folder
     break;
   }
}
else
{
   //show error message as not valid user
}


The best way to implement this senario is to first validate user with user name and password. And then validate type of user with user name and password. By using this technique you can display more appropriate error message.
 
Share this answer
 
v3
Comments
Tejas Vaishnav 3-Oct-12 7:21am    
that's what i want to tell... nice work Mohd. Mukhtar.
Mohd. Mukhtar 3-Oct-12 7:48am    
Thanks :-)
you can do something like this...


as you say on your login page you have two text boxes and one drop-down for selection of user type.

so if user select Admin from drop-down and enter his user name and password and if it will successfully login then you can redirect him to Admin\Home.aspx or if he/she will not successfully authenticated by username/password then refuse to login and stay on your login page. do same thing for Executive and redirect to Executive\Home.aspx
 
Share this answer
 

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