Click here to Skip to main content
12,699,492 members (32,587 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
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 3-Oct-12 0:59am
Comments
Anuja Pawar Indore 3-Oct-12 6:36am
   
Why repost? Update your previous question
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

for your requirements, i'm giving the simplest solution,

i guess u have newusertbl with columns username, password and usertype. The value of the column usertype should be either 'Admin' or 'Executive'. Also, ur dropdownlist has the values 'Admin' and 'Executive'.

in Login button click evt. use the following code:


protected void LoginBtn_Click(object sender, EventArgs e)
{
string qry = string.Empty;
qry = "select userType from NewUserTbl where username='" + TextBox1.Text.Trim() + "' and password='" + TextBox2.Text.Trim() + "'";
SqlConnection testDBConnection = new SqlConnection("Data Source=.;Initial Catalog=TestDb;Integrated Security=True");
testDBConnection.Open();
SqlCommand cmd = new SqlCommand(qry, testDBConnection);
string userType = Convert.ToString(cmd.ExecuteScalar());
if (string.IsNullOrEmpty(userType))
{
Response.Write("Invalid username or Password");
}
else if (RoleDDL.SelectedItem.Text == "Admin" && userType == "Admin")
{
Response.Redirect("Admin\\AdminHome.aspx");
}
else if (RoleDDL.SelectedItem.Text == "Executive" && userType == "Executive")
{
Response.Redirect("Executive\\ExecutiveHome.aspx");
}
}


Here,
TextBox1 is username TextBox,
TextBox2 is Password TextBox,
RoleDDL is the Dropdownlist.
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

then what is your question ? where u facing problem pls explain your particular problem ?
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 3 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100