I have designed the login page in C# with username and password as label and login as button. I want to write coding for this login page. How can i write. Here for example, the user should enter the login which is given by me.
Login Page
Hi,
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Micke BlomqvistPosted Feb 16, 2011, 4:22 AM
The link describes what you ask for, the example is in C# and not asp. Please mark as answered so others can use the post, as well. thank you.
Micke BlomqvistPosted Feb 17, 2011, 8:00 AM
Okay, I missunderstod you, mentioning a page and thought you meant a ASP.NET application.
In a Windows Form solution, just add the login form you've made in your static void Main() (usually in the Program class). Simply change the form name in the method; like this Application.Run(new your_login_form())
This will start your login form first, enabeling you to make validation against the database.
Create a procedure fetching the data from your "users-table" like this:
(Change to whatever suitable for your scenario)
CREATE PROCEDURE [dbo].[GetUserInfo]
@username varchar(10),
@pwd varchar(10)
AS BEGIN select userid, username, email from users where userid = @username and pwd = @pwd END
In your application, execute the sored procedure with the user entry values and if you get a record back, your user is validated. The just close the login form (your_login_form.Close()) start the form you originally had in your Application.Run(new frmOriginal()); method.
Short, but I'll guess you get the idea.
Vignesh RajaPosted Feb 16, 2011, 11:37 PM
Suthish NairPosted Feb 16, 2011, 3:52 AM
check Our recommended articles section.
Vignesh RajaPosted Feb 16, 2011, 3:19 AM
Micke BlomqvistPosted Feb 16, 2011, 12:33 AM
How have you decided to store the users username and password? You could go for differens soulutions here, one is for example to store the information in a SQL database and then select it based upon the users input and compare given pwd with the pwd stored in the database.
You could also check this Microsoft KB out if you think it's useful!
How To Implement Forms-Based Authentication in Your ASP.NET Application by Using C#.NET