Aslam-u-Alikuum Beautiful People
From Today We Are Starting ASP.NET Website Project
We are Making A Website For A School Home Work For Student
Means In This Project We Will Learn How To Insert View Update Delete
and Search Data with Sql Server + How to Make LogIn Page's Means Admin Login Page
And Student LogIn page wich is connected to Sql Server + How To Connect a Html5
website with ASP.NET Website and How To Publish It In Right Way :-)
So I Am Strating This Project Follow Me :-)
================================================
Part 1:
================================================
Log In Page Design View + C# programming Code + SQL Server
================================================
Step 1:
================================================
Desing View :
================================================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="admin login.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
#form1 {
height: 153px;
}
</style>
</head>
<body style="height: 243px">
<form id="form1" runat="server">
<asp:Label ID="Label4" runat="server" Text="Admin LogIn"></asp:Label>
<br />
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Id:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" style="margin-left: 96px"></asp:TextBox>
<div style="height: 25px">
</div>
<asp:Label ID="Label2" runat="server" Text="Password:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" style="margin-left: 51px" TextMode="Password"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="LogIn" Height="28px" style="margin-left: 467px" Width="74px" />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
================================================
Step2:
================================================
Sql Server Database code
================================================
Create Database schoolhomework
CREATE TABLE [dbo].[adminlogin](
[Id] [int] IDENTITY(1,1) NOT NULL,
[adminname] [nvarchar](50) NULL,
[paswword] [nvarchar](50) NULL,
CONSTRAINT [PK_adminlogin] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
================================================
Step 3
================================================
C# Code
================================================
On Page Load Event:
==================================
Label1.Visible = false;
==================================
On Button login Click event:
==================================
string user = TextBox1.Text;
string password = TextBox2.Text;
string userdb, passworddb;
returnclass rc = new returnclass();
userdb = rc.scalarReturn("select adminname from adminlogin where adminname='" + user + "'");
if (userdb==" ")
{
Label1.Text = "Invalid user name!";
Label1.Visible = true;
}
else
{
passworddb = rc.scalarReturn("select paswword from adminlogin where paswword='" + user + "'");
if (passworddb.Equals(password))
{
//fk_ad = rc.scalarReturn("select ad_id from admin_athu where ad_user='" + user + "'");
// HyperLink1.Enabled = true;
Response.Redirect("HWORK.aspx");
}
else
{
Label1.Text = ("Invalid Password!");
Label1.Visible = true;
}
}
===========================
C# return Class Code
==========================
public string scalarReturn(string q)
{
string s ;
SqlConnection conn = new SqlConnection(@"Data Source=DESKTOP-DODHH2V\SAAD;Initial Catalog=trialdatabase;Integrated Security=True"); //connection obj
conn.Open(); //opening connection
try
{
SqlCommand cmd = new SqlCommand(q, conn); //querry execution
s = cmd.ExecuteScalar().ToString();
}
catch (Exception)
{
s = " ";
}
conn.Close();
return s;
}
================================================
Part 1
Complete :-)
================================================
For Next Part Of This Project
Thumbs Up This Video
And
Subscribe To My Channel
And
Trun Notifications On
================================================
Till Next Time
Aslam-u-Alikum Beautiful People
================================================
No comments:
Post a Comment