Today I am going to show you how you can go about creating login page in asp.net website. Whenever you want to keep your information safe or stop unwanted traffic on your website, a login system works the best. My ongoing ASP.NET tutorial series will show you a complete demo of website creation. I will try my best to show you the easiest way to create a nice and secure website using ASP.NET. And therefore I would like to start with the login system.
First of all lets prepare Database containing a username and a password. Make sure you have a primary key as a username so that two usernames can never be registered.
Let’s make a form containing two text boxes and one button as shown in the picture below.
For creating a simple form in center of the page:
A simple backhand coding should be applied here. The next step is creation of SQL connection. For that we will simply RIGHT CLICK on the DATABASE ( here the database’s name it is“logindatabase” ) which is opened in SERVER EXPLORER and select PROPERTIES. Copy the entire CONNECTION STRING from the box which is open on the right side and arrange it as shown in the example below.
Now make a code for login system in button_click event as shown in the example. So that whenever the button is clicked, the following code will execute.
The process is very simple and checks whether user exists or not. Please send your comments if you have any questions.