Basic Login website without database connectivity

Basic Login website without database connectivity

Hello Friends, Today We will make a basic login website in which we will use two text boxes and three labels and a button.

Here is the design of the website. If you dont know how to create a website please follow our previous post “hello word asp .net website“.

basic login form in asp .net website
basic login form in asp .net website

The Design code is as :

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”default.aspx.cs” Inherits=”Admin_AdminLogin” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>

<html xmlns=””>
<head runat=”server”>

<body “>
<form id=”form1″ runat=”server”>
<table cellpadding=”5px”>
Username :
<asp:TextBox ID=”txtUserName” runat=”server” ></asp:TextBox>
Password :
<asp:TextBox ID=”txtPassword” TextMode=”Password” runat=”server” ></asp:TextBox>
<td colspan=”2″ align=”center”>
<asp:Button ID=”btnLogin” runat=”server” Text=”Login”
onclick=”btnLogin_Click” />



<td colspan=”2″ align=”center”><asp:Label ID=”lblError” runat=”server” ForeColor=”Red”></asp:Label></td>


Click on the button “Login” and write down the following code:

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;

public partial class Admin_AdminLogin : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

protected void btnLogin_Click(object sender, EventArgs e)
string UserName = txtUserName.Text.ToString();
string Password = txtPassword.Text.ToString();

if (UserName==”login” && Password==”password”)
lblError.Text = “Username and Password Are not Correct”;


website preview of login form in browser
website preview of login form in browser

As the code suggest, I had used username as “login” and “password” as password.

Use this to try to login the website. After clicking the login button you will see that there will be a new page name home.aspx which I created to show the use of response.redirect() function. This function is used to navigate to the given url(website address). The function response.redirect() uses a string as parameter and this can be absolute or reference url like here we have used a reference url.

To show error message we have used a label and we have assigned a text whenever a user used a wrong credentials. Please see the picture:

use of label control to show error message in asp .net
use of label control to show error message in asp .net

For password field textbox we use a property textmode=”password”  to hide the actual password characters.

We can also use placeholder property to set a watermark for text boxes like username and password.

To download complete project click here asp .net website login project without database connectivity

Author: admin

13 thoughts on “Basic Login website without database connectivity

  1. I have been surfing on-line greater than 3 hours nowadays, yet I never discovered any interesting article like yours. It is pretty price sufficient for me. Personally, if all web owners and bloggers made excellent content material as you probably did, the net might be a lot more helpful than ever before.
    tbdress prom dresses

  2. I see you don’t monetize your blog, i think there is one opportunity to earn additional $$$
    on your site, search in google for: idol4jp makes money

  3. Wow that was unusual. I just wrote an very long comment but after I clicked submit my comment didn’t show up.

    Grrrr… well I’m not writing all that over again.
    Anyway, just wanted to say great blog!

  4. Hi! This is my 1st comment here so I just wanted to give a quick shout out and
    say I really enjoy reading your articles. Can you recommend any
    other blogs/websites/forums that deal with the same subjects?
    Thank you!

  5. Hi there all, here every person is sharing these kinds
    of knowledge, therefore it’s fastidious to
    read this blog, and I used to go to see this weblog everyday.

  6. Whoa! This website looks just like my old one!

    It’s with a entirely different subject but it really
    has just about the identical layout and design. Wonderful collection of colors!

  7. Woah! I’m really loving the template/theme with this blog.
    It’s simple, yet effective. A great deal of times it’s hard to have that “perfect balance” between superb usability and appearance.
    I must say you’ve done a amazing job using this type of.
    Additionally, the blog loads super quick
    in my opinion on Chrome. Outstanding Blog!

  8. What’s Going on i am just a novice to this, I stumbled upon this I’ve found It absolutely
    helpful and it has aided me out loads. I
    hope to contribute & assist other users like its helped me.
    Good job.

Leave a Reply

Your email address will not be published. Required fields are marked *