ASP.Net & C# Login Page
Whenever we want to start any project the first thing we think about the User Roles and Login. Generally there will be mainly two User Roles
a) Administrator User
b) Client User
In VS 2005 its very simple to design a Login Page. Because there is no need of bringing textboxes, labels & buttons together to design a login page and writing code in that button click event. The VS 2005 have a readymade tool in its toolbox called as “Login”.
You just have to Drag & Drop that on your .aspx page
After drag & drop you can change that to your desired design by clicking on Auto Format
Then we need to go to the ‘Properties’ of that Login Control and click on Events.
There we can see a event called Authenticate, Double click on it.
Once that is done. You have to write the C# code in that event
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
try
{
string uname = Login1.UserName.Trim(); //Get the username from the control
string password = Login1.Password.Trim(); //get the Password from the control
bool flag = AuthenticateUser(uname, password);
if (flag == true)
{
e.Authenticated = true;
Login1.DestinationPageUrl = “After_Login.aspx”;
}
else
e.Authenticated = false;
}
catch (Exception)
{
e.Authenticated = false;
}
}
private bool AuthenticateUser(string uname, string password)
{
bool bflag = false;
string connString = “Server=localhost;Database=mproi;Uid=sa;Pwd=;”;
string strSQL = “select * from tbl_user where user_name ='” + uname + “‘ AND user_password ='” + password + “‘”;
DataSet userDS = new DataSet();
SqlConnection m_conn;
SqlDataAdapter m_dataAdapter;
SqlCommand m_Command;
try
{
m_conn = new SqlConnection(connString);
m_conn.Open();
m_dataAdapter = new SqlDataAdapter(strSQL, m_conn);
m_dataAdapter.Fill(userDS);
m_conn.Close();
}
catch (Exception ex)
{
userDS = null;
}
if (userDS != null)
{
if(userDS.Tables[0].Rows.Count > 0)
bflag = true;
}
return bflag;
}
}
That’s it. Its all Done. Your Login Page is ready. Its So Simple isn’t it!
good work
keep it up
good work mate..but still the code is not complete until and unless the database tbl_user is created.
cheers
coding part is good but ur not given full infomation about database.that should be some problem for learners………
hi..wat r d values for server & database..i gues database shud b table name…bt wt is 2 b entrd in server?
Gud Job man, its working!!
Cheers mate, this was pretty cool, but in case we’re were not using the Login object, how would we redirect the current page to another one?
In that case you have to write your own code and validate the username and password… to redirect from current page to your page Use
Response.Redirect(“yourpage.aspx”);
Hi ur Login Contol coding is very useful for me.It is simple and clear so beginners can understand easily.Thank u.
very good ,very good job.
thank you thank youuu =)))
Perhaps a better idea would be to use parameterizes queries:
string strSQL = “select * from tbl_user where user_name = @uname AND user_password = @password”;
…
m_Command.Parameters.Add(“@Username”, SqlDbType.VarChar).Value = uname;
m_Command.Parameters.Add(“@password”, SqlDbType.VarChar).Value = password;
i need better
gives me the error Must declare the scalar variable “@username” any ideas ? ive spent alot of time trying to work it out andi know parametarization is important for security reasons.
Thanks a lot
Good explanation of the login process.
I got a bit confused, because I had used SqlMembershipProvider with its automated database schema and discovered that it worked without a line of code in AuthenticateUser event. When user click on Login button, asp.net automatically do complete login process. That is much simplier for beginners like me 🙂
I guess this tutorial is about using Login control with your own tables (tbl_user)…
So, my question would be: which way is better practice – create your own tables or use aspnet_regsql.exe to do all the work?
I WANT, HOW TO CREATE A WEB PAGE BY USING ASP.NET WITH C#. I NEED SAMPLE WEB FORM AND CODING.
this web-form is very simple.try it if you need any help then i will help u
Hey Priya. I need some help. I was taking a look at the login forms guide for asp.net C#. So far, i’ve only came across tutorials where login page authorized according to one database table. Imagine I have 4 tables in my database now.
Customer Table has “username” , “password” , and “RoleID” table column where RoleID is the primary key.
Employee Table is the same. “username” , “password”, and “RoleID” table column where RoleID is the primary key.
Supplier Table is also the same. “username” , “password” and “RoleID” table column where RoleID is the primary key.
Roles Table has “RoleID” and “Name” table columns and RoleID is the primary key.
Example:
Role ID Name
1 Customer
2 Admin
3 Supplier
How do I create a login page, to allow user(either customer, employee, or supplier) to type in their username and password which will check with the 3 database tables Customer, Employee and Supplier. And if the account exist, means the user definitely belong to either one of the user type(Customer, Admin, Supplier). And if user belongs to Customer table, Response.Redirect(CustomerHomePage.Aspx).
I sincerely hope you’ll get back to me as soon as possible. Would appreciate your help. Thank you.
You can reply me back through my email android_trasher@hotmail.com
i am beginner in asp.net. i want help. please help me to learning more asp.net
hi ganesh
thnk u for the code
but i am fresher regarding database i am not getting the o/p
if possible can u get the code
as i am saying because i tried severaltimes but i am not getting
1ce again thnks for this
Hi Upender,
What exactly are you trying… I need some more information on it… My personal Email is ganeshmohan99@gmail.com. you can contact me any time…
Thanks & Regards
Ganesh Mohan
hai……u have explianed it by using login control….. can u explain me it by not using login control…… or can u send me the code for login page which should be designed using textboxes end lables not control(login)………….
Thanks…………………in advance
this is karimulla i sent you gmail invitation pls accept it if i have any doubt s i will contact u
hi ganesh, im also a beg n d code s nt wrkn..
Hi Ganesh Mohan
Thanks. it was quit useful for me!
Please can u give me info about your database,
do I have to have a flag coloum with boolean type and with true for the admin and false for the client or what ??
I am using my SQL
Hi Mona,
You can use a flag field in database for admin & client user roles but in case if you have 2 or more user roles then you have to create a table called UserRole and set a foreign key as userrole_id in User table.
Regards
Ganesh Mohan
thnz…
its very gud
got lot of things…
Hi Ganesh,
Thank u very much (:
Today I remove my sql database and used windows sql server,
I have a table called login and I have added a coloum called flag it has to conditions “a” or “c”, admin and client.
Now the problem is, when I run this application in visual studio the form is working but I think the connection to the database is missing because even if I Enter a correct username and password it gives me the same message! ” Your login attempt was not successful. Please try again.”
I changed the connection and the name of the table with the coloum!
string connString = “data source= mona;”;
also I have added this:
public String flagu;
then I check it if the user is admin it must be directed to specific page :
if (flagu == “a”)
// {
// Response.Redirect(“something.aspx”);
// if (flagu == “c”)
// {
// Response.Redirect(“Other.aspx”);
// }
// }
but it is not working I dont know why!!
could you help me please (:
Hi Mona,
Change the flag field data type to Boolean instead of string and check flagu == true/false. If it does not work contact me on skype or GoogleTalk so that we can make it clear…
SkypeID is ganeshmohan99
Gmail a/c is ganeshmohan99@gmail.com
We can chat and clear ur doubts there.
Regards
Ganesh
Hi Ganesh
thank you for the code.It is simple and clear ,
I am fresher regarding .net and database also I am doing online bookshoping project in that I displayed book categories in category.aspx and while user selects a book and cliks on it ,it goes to details.aspx page there I shoud display the related books of the book.
In this page I have to display the related book aswell it details while user cliks on it.
can you please guide me.
as i tried severaltimes but i am not getting .
Hi Vani,
Sure I will help you… But nowadays a bit busy anyhow you can mail me or send a Gtalk chat request to my Gmail ID if you have a gmail account. So that problems can be solved then & there only…
Regards
Ganesh
RATHER THAN OPENING DATA ADAPTOR & DS, U CAN DIRECT FIRE COMMAN.EXECUTENONQUERY, & STORE RESULT IN VARIABLE, THAT MEANS HOW MANY ROW IS AFFECTED, IF ROW AFFECTED > 0 THAN USERNAME & PASSWORD VALID ELSE ROWAFFECTED < 0 THEN INVALID USERNAME OR PASSWORD.
could u help me with the database creation
Let me Try… What is it??
Hai ganesh this is Rajesh
this code is very good
I understand how this works and how simple a system it is i’m however not sure about how you prevent users from accessing the after_login page directly i presume this is something in teh webconfig im just not sure what
Hi Jake,
Its not the web config file… its about sessions which take care of this process. In login page when login details matches store the user object in the session and check the session in after_login page if session is not null allow him to access that page else if session null redirect to login page. Simple 🙂
Ganesh
amazing post.
very basic.this is what i was looking for.
job done.
thank you.
keep it up.
Thank You!
really awesome tut. thank you very much for such a contribution. just had one question, am trying to connect to my DB which has values i out in. i set the the connectionString and all but it is still non responisve. it keeps failing to validate a user that should be validated. i understand all ur code n can not see the problem. any furst guesses?
thanx Mohan
Hi Ganesh,
I am doing .Net coding for first time. Your code is good, but what we can do if the user is logging for first time?
How can we modify this code for, first time users for sign up and storing the details in database.
excellent. this post save my Project.. Thank you very much
Wonderful articel Ganesh,
I started with ASP .net, this is my first dev work…
Is it possible for you to help with >
thanks
hi ganesh,
In my project i have a login page in that i have used that code.In my project i changed databse name to my databse name i.e. Anil-PC\SQLEXPRESS, then it is showing me the error i.e
Error 1 Unrecognized escape sequence C:\Users\ Anil\Documents\Visual Studio 2008\WebSites\WebSite1\Default.aspx.cs 83 63 C:\…\WebSite1\
could you please tell me the solution for this….
C:\…\WebSite1\
just give one more backslash where already one backslash is there.
like this
=C:\\…\\WebSite1\ \………\\
to anil
great job yaar
can u give the code for storing and displaying images in asp.net c#..
Hi,
i follow the code u posted here to do my project. But i wonder why it keep saying my username n password incorrect although i put in a valid one.
Can you please help me? thx
Hi,
Excellent coding work. You have certainly reduced a lot of my efforts at this. However, I have one problem. Whatever details I enter in the username and password, i get the error saying login failed, try again later. I checked my database connectivity, coding(which is basically yours) and everything else I could think of. But to no avail. Do you have any clues as to what might be going wrong
Thanks mate..!!
Hi, Thanks for your code. I followed everything, but now I have a question about the “Flag” column in the tbl_User table.
My situation is I have more than one roles, so I created a new table, tbl_Web_Role. I created the Foregin to the tbl_User.
So, I changed code a bit but it gave me the error message, “Cannot implicitly convert type ‘bool’ to ‘string'”.
Can you please explain the error message?
Thanks.
The error is about your datatype… I used flag as boolean but you are using role type as integer or string… you need to check with your datatype in database and match accordingly in code…
Hi, thanks for the code… but everytime i try to login, me getting error: “Your login attempt was not successful. Please try again”. Could u assist on this..? me still beginner for this .net.. tq..
I think its DB conn.. check out database connection… in coding trace by giving some catch{label1.Text = ex.ToString()} but before that add some label in ur page…
thx for help
Hello Ganesh,
I saw the code given by u and its fantastic.
But i was planning to develop a login page without using any of the two i.e. Data Reader or Data Adapter.
So could u please guide me how can i do it in a simpler way without using these two.
Thank you very much for help.this code is very helpful to me.thanks again
hi ganesh,
thanks for your help, can you explain structure of the table for this login.
thanks
hari
hai ganesh,
i need information about feedback facilities for my project.
how can i create the code for that please help me regarding this
with regards,
s.sribharanidharan
Its really good thank u
really helpfull…
i thnk only mine code is nt running ,,,,,,,,,,,, i hv tkn login control nd thn done copy and paste ths coding nd thn i ws trying to create database by the name of localhost(server),database(mproi),user name(sa)and password(;). bt it is gvng error tht u cnt connect to remote server,,,,,,,,,,,,,,,, wht is ths plz tell me………….
its good bt i am using visual studio 2008 i dragged the login but i could not find events in its properties what shud i do?
plz help
dear shelly,
on properties….try have a look at the top icon….the orange color icon,wen u run out ur cursor it will appear “events”…
hope its can help u dear.
im also newbie
ooopssssss i hav found my answer and my form is working
thanx a lot its really very helpful
thanks very2 much…for tis tutorial…
its really wrkg for me..im happy
thanks again
simply beautiful and and excellent example for beginner
Hi,
can somebody tell me where the ‘Login’ come from in this part of code:
string uname = Login1.UserName.Trim(); //Get the username from the control
string password = Login1.Password.Trim(); //get the Password from the control
thanks
great job man, thank soooooo much. That was very clear.
when log on how do we distinguish between server and client.. how do we check from data base???
Hello Ganesh,
The code which I was searching has been found at your blog, good work, Actually i need to some modifications as I am using backend as access, I have done that, Its very simple and easy to understand, thank you very much
Sunil Kumar Bairam
hai……this code is very nice for the Beginners,but here u have explained by using login control….. can u explain me it for without using login control…… or can u send me the code for login page which should be designed using textboxes end lables not control(login)………….
hi again it’s me ..I’ld lik to create a login page using textboxes..that is if i click submit button the page is redirected to the another page containing signup page…signup page also i hav using text boxes not the controls…my dout is if i have enter the details in the signup page it’s automatically saved in my database and my page is redirected to the login page…can u please send me the code for loginpage and signup page……
Hi.
I am doing a project in C# with a oracle database .
I dont know how to access a data in 2nd form according to the login page(first page).
can you please help me over this.
Hello sir im new to C#.I have to do project in c# with backend SQL server.So please provide the info i.e how to work with SQL server.And suggest me some books to learn SQL server.
ThanQ
Hi Ganesh,
I hav a Error in this line…
bool flag = AuthenticateUser(uname, password);
if (flag == true)
when the program executes, it does not shows any error bt flag always goes false..
plz help me…
hi
Sir i want the code in c#
i ve a project like this
i wnt to store information of teaching staff in database(SQLserver) without the field (Department like mca,mba).
But in frontend when i give an id(mc101),it has to display dept.name.How to write code in c#.
hi,
i have one doubt, i need the coding for, how to lock the account,if the password is wrong, to entered the 5 times
hi bala,
its quite easy… keep a field in your table say “attempts” and set default value as ‘0’ whenever authenticate fails in code increment this value and store back to database. before authenticate check if your “attempts” crossed 5 or not…
Thanks
Ganesh
hai ganesh
you have explained it by using log in control…..
can u explain me it by not using log in control…… or can u send me the code for login page which should be designed using textboxes end lables not control(login)………….
i am waiting for ur reply.
Thanks…………………in advance
hi,
thanks a lot…i was tried to login control for your coding…really it’s well also very simple…
i am new in asp plz help me for login coding when i am using window authentication mode for sql
Good job ganesh!! but i have lots of doubts in asp.net c#. can u help me out?
Man I love your blog, I will be here ateast twice a week.
i hav perfectlly understand user control………..
thanks…………
hii ganesh
I want login code using oracle database…. can you please help me……… i want it urgently…
i am waiting for ur reply.
thanx…..
Thanku very much i learn new things in this page
I need some help. I was taking a look at the login forms guide for asp.net C#. So far, i’ve only came across tutorials where login page authorized according to one database table. Imagine I have 4 tables in my database now.
Customer Table has “username” , “password” , and “RoleID” table column where RoleID is the primary key.
Employee Table is the same. “username” , “password”, and “RoleID” table column where RoleID is the primary key.
Supplier Table is also the same. “username” , “password” and “RoleID” table column where RoleID is the primary key.
Roles Table has “RoleID” and “Name” table columns and RoleID is the primary key.
Example:
Role ID Name
1 Customer
2 Admin
3 Supplier
How do I create a login page, to allow user(either customer, employee, or supplier) to type in their username and password which will check with the 3 database tables Customer, Employee and Supplier. And if the account exist, means the user definitely belong to either one of the user type(Customer, Admin, Supplier). And if user belongs to Customer table, Response.Redirect(CustomerHomePage.Aspx).
pls kindly reply me as soon as possible…
can u send me the code for login page which should be designed using textboxes end lables not control(login)………….
hi
hi. I like ur code, but there is one problem. i rewrite the code but the error is- user name and password field in the connection string. wht to do. i tried all the way. but not yet successful. plz help me.
thank you
goood job friend friend iu realy appriciate your work it help all the fresher developer to build themselves .
thanks.
Thanks a Lot… 🙂
hi ganesh,
i like ur code.i want code for createuserwizard control can u help me.
using the database.
“There is already an open DataReader associated with this Command which must be closed first.” The above error occurred while I using multiple SqlDataReader. Pls give me the solution
hi,
This is srikanth. i like ur code. can u send me the code for “CreateUserWizard” control plz
Hi! I’ve just tried this and it work nice. I’m thinking of inserting a parameter like what Anon have done but I’m getting some error like Error: Unassigned local variable ‘m_Command’ so what do I need to do to make it more secure to SQL Injection?
Any help would be much appreciated!
Thanks in advance.
Dear Ganesh.
I used this tutorial as you have explained. i have correctly put the connection string and the other parts of cording.
but when i enter the user name and password i get the error message saying logging failed, try again.
please help me on this!
Thank you very much..
keep up the good work
hi,
I m fresher, I m designing a asp.net website in which I want to maintain a login as per different user where they should able to view the pages as per there hierarchical order example
Admin can view all the pages……..Manager can view only his pages and the pages his junior pages………
how can I design a login for this,database and how I code for accessing page as per the login……………
Please help me out
thank you,
hi sir my Problem is image show in grid view but not show
database fetch image name & path(image name & path store in column)and image store in website folder
ple help
i need a codings for my login page in my website using c#.net … If i tryed more than times with wrong username or password means it terminates that login page and come out from that project tell me some idea
Hey.. To all i need one help pls try to provide code for if a user enter in login page and type login name & password after that he clicks button login it goes to login page in that i watn add a login name .. i need that login name code
thanx a lot ur code really help me out bt wud u plz give me dis same code for microsoft access database
Hello Sir, Good Evening. I am having some Problems with Database Storage for Login form. Please tell me how to use database for this
Hey I need some help. I was taking a look at the login forms guide for asp.net C#. So far, i’ve only came across tutorials where login page authorized according to one database table. Imagine I have 1 table in my database now.
User_table has “username” , “password” , and “RoleID” table column where RoleID is the primary key.
Example:
Role ID Name
1 Customer
2 Admin
3 Supplier
How do I create a login page, to allow user(either customer, employee, or supplier) to type in their username and password which will check with the 1 database table i.e User_table. And if the account exist, means the user definitely belong to the User_table the user type(Customer, Admin, Supplier). And if user’s RoleID name is costumer Response.Redirect(CustomerHomePage.Aspx).
I sincerely hope you’ll get back to me as soon as possible. Would appreciate your help. Thank you.
You can reply me back through my email vishuinnocent@gmail.com
how to populate from database to a dropdownlist. using another dropdownlist to populate information
hi friend. very useful your code. keep in up.
hi..
i created one ms aceess database(db1), in that i have login table…
and in my aspx page i have username, password and login button…
please send me code for login in asp.net using c# language.
Thank u for the code. It helped me for completion of my colg project.
Thankyou dear,
U have made this problem really a piece of cake………..Thankyou very much………….
This is awesome ! thanks for sharing with us. It’s help me lot and this link..
http://www.mindstick.com/Articles/f55de7c4-0b0c-4295-a19b-7dd654755c6b/?Login%20form%20in%20ASP.Net
also helped me to complete my task.
Thanks !
hey ganesh , really very gud wrk..thx.
what should i do with m_command, why we don’t use it
if we try to get data on the basis of userid and password like “Select * from tablename where userid=’value’ and passwd=’value’ then the sql injection will work and any one can get logged in.
try to do this
1-select all the table from query in a datatable .
2-then match userid ,password fields from datatable to the inputs(i.e. userid,passwd) it will work fine.no sql injection can work on this.
This is best one article so far I have read online. I would like to appreciate you for making it very simple and easy. I have found another nice post related to this post over the internet which also explained very well. For more details you may check it by visiting this url…..
http://mindstick.com/Articles/c389febe-fceb-4cb9-a4d1-41259346f449/?Login%20Form%20in%20ASP.Net
Thanks everyone for your precious post!!
Hi…..
canyou please give me login code in asp.net using c#….
thanks a lot baddy…….,,iam trying this for 2 days….
canyou please give me login code in asp.net using c#…PLS:(
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace formlogin
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter();
SqlConnection connection = new SqlConnection(“data source=rehan-PC\\SQLEXPRESS; database=logindb; integrated security=true”);
connection.Open();
da.SelectCommand = new SqlCommand(“select i.d from logintbl where USERNAME='” + TextBox1.Text + “‘, PASSWORD='” + TextBox2.Text + “‘”, connection);
connection.Close();
DataTable dt = new DataTable();
if (dt.Rows.Count > 0)
{
Response.Redirect(“homepage.aspx”);
}
else
{
Response.Write(“user doesn’t exist”);
}
}
}
}
anyone pls tell mistake in dis code 😦 it didn’t work
Hai Ganesh,
This code is very useful for me.
hi all,
pls be inform the coding of login control with remember me checkbox
Thanks mate, just what I was looking for
i m going to project in asp.net using c#…i want to know how to connect with the mysql database…..
thank you so much ganesh i have been breaking my head to get the output
thanks a lot
Nice post. I learn something totally new and challenging on websites I stumbleupon every day.
It’s always exciting to read articles from other writers and use a little something from their web sites.
What’s up, I wish for to subscribe for this website to take hottest updates, so where can i do it please help out.
I personally wanted to present this blog post, “ASP.
Net and C# Login Page Ganeshmohan’s Weblog” along with my best friends on facebook or twitter. I personallyjust simply wished to pass on your tremendous writing! Thx, Melina
Right here is the right webpage for anybody who would like to find
out about this topic. You know a whole lot its almost hard to argue
with you (not that I really will need to…HaHa). You certainly put a brand new spin on a topic which has been written about for a long time.
Excellent stuff, just great!
Hi,
I’ve tried your code, but i want some more code to execute.
I want to autenticate the login page, if username i entered related to User/Admin then it shoub be redirected to two pages like if it is user redirect to userpage, if it is admin ,redirect to admin page
please help me
Ok… add a column in your table like is_admin which is a boolean. after authenticating check with if condition if is_admin is true then redirect to admin page else redirect to user page.
Hi!
This is a nice article. Thanks for sharing your knowledge. I have read some other links that’s also helpful for beginner.
http://www.aspdotnet-suresh.com/2011/12/how-to-create-simple-login-form-using.html
http://www.mindstick.com/Articles/f55de7c4-0b0c-4295-a19b-7dd654755c6b/?Login%20form%20in%20ASP%20Net
http://www.mindstick.com/Articles/c389febe-fceb-4cb9-a4d1-41259346f449/?Login%20Form%20in%20ASP.Net
After looking into a few of the articles on your blog,
I honestly appreciate your technique of writing a blog. I saved as a favorite it to my bookmark
webpage list and will be checking back soon. Take a look at
my web site too and tell me what you think.
Hurrah! In the end I got a website from where I can genuinely obtain helpful information concerning my study and knowledge.
Re: How to check Entered textbox value and database values are equal or not?
06-07-2013 05:13 AM|LINK
Actual this is my code I don’t want to delete code Sessions
Without deleting my actual code (if(clientId!=Null sessino code)
Where i am putting that code???
please help me any one
string clientid;
string strCon = @System.Configuration.ConfigurationManager.ConnectionStrings[“stgdbConnectionString”].ConnectionString;
string strSelect = “SELECT ClientId FROM CLIENT WHERE Email = @Email AND Password = @Password”;
//string strSelect1 = “select ClientId from CLIENT where Email = @Email AND Password = @Password”;
SqlConnection con = new SqlConnection(strCon);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = strSelect;
SqlParameter email = new SqlParameter(“@Email”, SqlDbType.VarChar, 50);
email.Value = txtEmail.Text.Trim().ToString();
cmd.Parameters.Add(email);
SqlParameter password = new SqlParameter(“@Password”, SqlDbType.VarChar, 50);
password.Value = txtPwd.Text.Trim().ToString();
cmd.Parameters.Add(password);
con.Open();
clientid = cmd.ExecuteScalar().ToString();
con.Close();
if (clientid != null)
{
Session[“Emailid”] = txtEmail.Text.ToString().Trim();
Session[“ClientId”] = clientid;
Response.Redirect(“Logout.aspx”);
}
else
lblMsg.Text = “Incorrect EmailId or Password”;
And what about the three layers? that code is bad…. For exapmle is good but in the real world no
Hello Dear, are you in fact visiting this website daily, if so
then you will absolutely obtain pleasant experience.
I am sure this post has touched all the internet people, its really really nice piece of writing on building up new web site.
what is the Login1_destinationPageUrl = “after_login.aspx”;