Below is the code which will demonstrate how to design login functionality in asp.net using C# by with the help of web configuration file. Please note the login details are used as a static.
The Web configuration file is:
The Web configuration file is:
The below is the design view of the project:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="ShoppingHeart.Admin.Login" %>
Style="font-weight: 700">
LoginID :
Password :
Below is the code view:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
namespace ShoppingHeart.Admin
{
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
txtLoginID.Focus();
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string LoginID = WebConfigurationManager.AppSettings["AdminLoginID"];
string Password = WebConfigurationManager.AppSettings["AdminPassword"];
if(txtLoginID.Text== LoginID && txtPassword.Text == Password)
{
Session["ShoppingHeartAdmin"]= "ShoppingHeartAdmin";
Response.Redirect("~/Admin/AddNewProducts.aspx");
}
else
{
lblAlert.Text = "Incorrect LoginID / Password";
}
}
}
}
Comments
Post a Comment