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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Micke BlomqvistRank #1,660 · 923 reputationPosted Feb 15, 2011, 11:22 PM EST
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 BlomqvistRank #1,660 · 923 reputationPosted Feb 15, 2011, 7:33 PM EST
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
Vignesh Raja6 reputationPosted Feb 15, 2011, 10:19 PM EST
Suthish NairRank #92 · 22.8K reputationPosted Feb 15, 2011, 10:52 PM EST
check Our recommended articles section.
Vignesh Raja6 reputationPosted Feb 16, 2011, 6:37 PM EST
Micke BlomqvistRank #1,660 · 923 reputationPosted Feb 17, 2011, 3:00 AM EST
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.