Login

Published on June 2016 | Categories: Documents | Downloads: 98 | Comments: 0 | Views: 818
of 11
Download PDF   Embed   Report

Login Page Design

Comments

Content

Login
Design
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<center><table style="width: 230px">
<tr><td height="20" colspan="2" align="center"><asp:Label ID="Label1" ForeColor ="red"
runat="server" Text="" Visible ="false"></asp:Label></td></tr>
<tr><td align="right"><asp:Label ID="Label2" runat="server" Font-Bold="True"
Style="position: static" Width="97px">Login Name :</asp:Label></td>
<td>&nbsp;<asp:TextBox
ID="txt_id" runat="server" Style="position: static" TabIndex="1" Width="145px"
Height="25px"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txt_id" ErrorMessage="*"></asp:RequiredFieldValidator></td></tr>
<tr><td align="right" class="style2"><asp:Label ID="Label4"
runat="server">Password :</asp:Label></td>
<td class="style3"> &nbsp;<asp:TextBox
ID="txt_pwd" runat="server" TextMode="Password" TabIndex="2" Width="145px"
Height="25px"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txt_pwd" ErrorMessage="*"></asp:RequiredFieldValidator></td></tr>
<tr>
<td align="right" class="style1">
<asp:Label ID="Label3" runat="server" Text="User Type :"></asp:Label></td>
<td class="style1">
<asp:DropDownList ID="DropDownList1" runat="server" Width="145px"
Height="25px">
<asp:ListItem>---Select---</asp:ListItem>
<asp:ListItem>User</asp:ListItem>
<asp:ListItem>Admin</asp:ListItem>
<asp:ListItem>Teacher</asp:ListItem>
</asp:DropDownList>
</td>
</tr>

<tr><td colspan ="2" align="center" height="25">
<br />
<asp:Button ID="Button2"
runat="server" Style="position: static; font-weight:100;" Text="Log In" Width="126px"
TabIndex="5"
CssClass="bttn" onclick="Button2_Click" Font-Bold="True"
ForeColor="#3399FF" Height="30px" /></td></tr>
</table></center>
</asp:Content>

Backed Code
using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Web;
System.Web.UI;
System.Web.UI.WebControls;
System.Data;
System.Data.SqlClient;

public partial class login : System.Web.UI.Page
{
connection con=new connection();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
string st1 = txt_id.Text;
string st2 = txt_pwd.Text;
string st3 = DropDownList1.SelectedValue;
con.open_connection();
string str = "select * from login where emaiid='" + txt_id.Text + "'";
SqlCommand cmd = new SqlCommand(str, con.con_pass());
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (st1 == dr["emaiid"].ToString() && st2 == dr["password"].ToString() && st3 ==
"User")

{
Session["username"] = st1;
Session["ctime"] = DateTime.Now.ToShortTimeString();
Response.Redirect("StudentProfile.aspx");

"Admin")

}
else if (st1 == dr["emaiid"].ToString() && st2 == dr["password"].ToString() && st3 ==
{

Response.Redirect("userlist.aspx");
}
else if (st1 == dr["emaiid"].ToString() && st2 == dr["password"].ToString() && st3 ==
"Teacher")
{
Session["username"] = st1;
Response.Redirect("teacherProfile.aspx");

}
else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage",
"alert('Check User Name and Password and contact for admin for approval')", true);

}
}
con.close_connection();

}
}

Register
Design
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true"
CodeFile="register.aspx.cs" Inherits="register" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style1
{
width: 229px;
}
</style>
<script type="text/javascript" src="js/calendar.js"></script>
<script type="text/JavaScript" src="js/scw.js"></script>
<link href="Styles/calendar.css" rel="stylesheet" type="text/css" media="screen" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<center>
<h1>Register Student </h1>
<hr />
<table id="Table2" align="center"
style=" padding: 011px; height: 476px;">
<tr>
<td align="right">
<asp:Label ID="Label17" runat="server" Text="User ID :"
ForeColor="Black"></asp:Label></td>
<td class="style1">
<asp:TextBox ID="txtID" runat="server" Width="145"
ReadOnly="true"></asp:TextBox></td>
<td align="center" colspan="3" height="25">
<asp:Label ID="Label9" runat="server" Font-Bold="True" ForeColor="Red"
Visible="False"></asp:Label></td>
</tr>
<tr style="color: #000000">
<td align="right" height="25">
<asp:Label ID="Label19" runat="server" Text="Email ID :"></asp:Label>
</td>
<td class="style1" >
&nbsp;<asp:TextBox ID="txtEmail"
runat="server" Width="145px" ></asp:TextBox>
</td>
<td align="right" style="width: 147px">
<asp:Label ID="Label20" runat="server" Text="Confirm Email ID :"></asp:Label>

</td>
<td>
<asp:TextBox ID="txtcEmail" runat="server" Width="145px"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator2" runat="server"
ControlToCompare="txtEmail" ControlToValidate="txtcEmail"
ErrorMessage="Email ID not Matched"></asp:CompareValidator>
</td>

</tr>
<tr style="color: #000000">
<td align="right" height="25">
<asp:Label ID="Label1" runat="server" Text="First Name :"></asp:Label></td>
<td class="style1">
<span style="font-size: 7pt; color: #ff0000">&nbsp;</span><asp:TextBox
ID="txtFname"
runat="server" ReadOnly="false" Width="145px"></asp:TextBox>
</td>
<td align="right" style="width: 147px">
<asp:Label ID="Label15" runat="server" Text="Last Name :" ></asp:Label>
</td>
<td>
<asp:TextBox ID="txtLName"
runat="server" ReadOnly="false" Width="145px" maxlength="25"></asp:TextBox>
</td>
</tr>
<tr style="color: #000000">
<td align="right">
<asp:Label ID="Label16" runat="server" Text="Gender :"
ForeColor="Black"></asp:Label></td>
<td class="style1">
<asp:RadioButtonList ID="radGen" runat="server" ForeColor="Black">
<asp:ListItem Text="Male" Value="male"></asp:ListItem>
<asp:ListItem Text="Female" Value="female"></asp:ListItem>
</asp:RadioButtonList>
</td>

<td align="right" height="25">
<asp:Label ID="Label6" runat="server" ForeColor="Black" Text="Father's
Name :"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtFather" runat="server" CausesValidation="True" MaxLength="30"
TabIndex="3" Width="145px"></asp:TextBox>
</td>

</tr>
<tr style="color: #000000">
<td align="right" height="25">
<asp:Label ID="Label2" runat="server" Text="Password :"></asp:Label></td>
<td class="style1" >

&nbsp;<asp:TextBox
ID="txtPass" runat="server" MaxLength="15" TabIndex="1" TextMode="Password"
Width="145px"></asp:TextBox>
</td>
<td align="right" style="width: 147px">
<asp:Label ID="Label14" runat="server" Text="Confirm Password :"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtcPass" runat="server" MaxLength="15" TabIndex="1"
TextMode="Password"
Width="145px"></asp:TextBox>

<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txtPass" ControlToValidate="txtcPass"
ErrorMessage="Password Not Matched"></asp:CompareValidator>

</tr>

</td>

<tr>
<td align="right" height="25">
<asp:Label ID="Label13" runat="server" ForeColor="Black" Text="Date Of
Birth :"></asp:Label>
</td>
<td class="style1">
<asp:TextBox ID="TextBox1" onClick="scwShow(this,event)"
runat="server"></asp:TextBox>

</td>
</tr>
<tr>
<td align="right" height="25">
<asp:Label ID="Label4" runat="server" ForeColor="Black"
Text="Address :"></asp:Label>
</td>
<td class="style1">
&nbsp;<asp:TextBox ID="txtAdd" runat="server" CausesValidation="True"
Height="58px"
MaxLength="250" TabIndex="7" TextMode="MultiLine"
Width="150px"></asp:TextBox>
</td>
<td align="right" height="25">
<asp:Label ID="Label5" runat="server" ForeColor="Black" Text="City :"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtCity" runat="server" Width="145px"></asp:TextBox>
</td>
</tr>

<tr>
<td align="right" height="25">
<asp:Label ID="Label3" runat="server" ForeColor="Black"
Text="State :"></asp:Label>
</td>
<td class="style1" >
<asp:DropDownList ID="txtState" runat="server" TabIndex="9" Width="145px">
<asp:ListItem Text="----Select----" Value="n"></asp:ListItem>
<asp:ListItem Text="Andhra Pradesh"></asp:ListItem>
<asp:ListItem Text="Assam"></asp:ListItem>
<asp:ListItem Text="Bihar"></asp:ListItem>
<asp:ListItem Text="Chhattisgarh"></asp:ListItem>
<asp:ListItem Text="Goa"></asp:ListItem>
<asp:ListItem Text="Gujarat"></asp:ListItem>
<asp:ListItem Text="Haryana"></asp:ListItem>
<asp:ListItem Text="Jammu and Kasmir"></asp:ListItem>
<asp:ListItem Text="Jharkhand"></asp:ListItem>
<asp:ListItem Text="Karnataka"></asp:ListItem>
<asp:ListItem Text="Maharashtra"></asp:ListItem>
<asp:ListItem Text="Madhya Pradesh"></asp:ListItem>
<asp:ListItem Text="Manipur"></asp:ListItem>
<asp:ListItem Text="Meghalaya"></asp:ListItem>
<asp:ListItem Text="Mizoram"></asp:ListItem>
<asp:ListItem Text="Nagaland"></asp:ListItem>
<asp:ListItem Text="New Delhi"></asp:ListItem>
<asp:ListItem Text="Orissa"></asp:ListItem>
<asp:ListItem Text="Punjab"></asp:ListItem>
<asp:ListItem Text="Rajasthan"></asp:ListItem>
<asp:ListItem Text="Sikkim"></asp:ListItem>
<asp:ListItem Text="Tamil Nadu"></asp:ListItem>
<asp:ListItem Text="Tripura"></asp:ListItem>
<asp:ListItem Text="Uttar Pradesh"></asp:ListItem>
<asp:ListItem Text="Uttarakhand"></asp:ListItem>
<asp:ListItem Text="West Bengal"></asp:ListItem>

</asp:DropDownList>
</td>
<td align="right" height="25">
<asp:Label ID="Label21" runat="server" ForeColor="Black" Text="Postal
Code :"></asp:Label>
</td>
<td colspan="2">
&nbsp;<asp:TextBox ID="txtPostal" runat="server" CausesValidation="True"
MaxLength="6"
TabIndex="10" Width="145px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" height="25">
<asp:Label ID="Label7" runat="server" ForeColor="Black"
Text="Semester :"></asp:Label></td>
<td class="style1">
&nbsp; <asp:DropDownList ID="txtCountry" runat="server" TabIndex="9"

Width="145px">
<asp:ListItem Text="----Select----" Value="n"></asp:ListItem>
<asp:ListItem Value="sem1">Sem1</asp:ListItem>
<asp:ListItem Value="sem2">Sem2</asp:ListItem>
<asp:ListItem Value="sem3">Sem3</asp:ListItem>
<asp:ListItem Value="sem4">Sem4</asp:ListItem>
<asp:ListItem Value="sem5">Sem5</asp:ListItem>
<asp:ListItem Value="sem6">Sem6</asp:ListItem>
<asp:ListItem Value="sem7">Sem7</asp:ListItem>
<asp:ListItem Value="sem8">Sem8</asp:ListItem>
</asp:DropDownList>
</td>
<td align="right" height="25">
<asp:Label ID="Label8" runat="server" ForeColor="Black" Text="Phone
No :"></asp:Label>
</td>
<td colspan="2">
&nbsp;<asp:TextBox ID="txtPone" runat="server" CausesValidation="True"
MaxLength="10"
TabIndex="10" Width="145px"></asp:TextBox >

</td>
</tr>
<tr>
<td align="right" height="25">
<asp:Label ID="Label10" runat="server" Text="Branch :"
ForeColor="Black"></asp:Label></td>
<td >
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="CSE">CSE</asp:ListItem>
<asp:ListItem Value="Electrical">Electrical</asp:ListItem>
<asp:ListItem Value="Mechanical">Mechanical</asp:ListItem>
<asp:ListItem Value="Civil">Civil</asp:ListItem>
</asp:DropDownList>
</td>
<td align="right" height="25">
<asp:Label ID="Label11" runat="server" Text="Section :"
ForeColor="Black"></asp:Label></td>
<td >
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem Value="A">A</asp:ListItem>
<asp:ListItem Value="B">B</asp:ListItem>
<asp:ListItem Value="C">C</asp:ListItem>
<asp:ListItem Value="D">D</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="center" colspan="5" style="height: 24px">
<asp:Button ID="Button1" runat="server" CssClass="bttn"
Text="Register Student" onclick="Button1_Click1" ForeColor="#0066FF" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</td>
</tr>
</table>
</center>

</asp:Content>

Backed Code
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.Web;
System.Web.UI;
System.Web.UI.WebControls;
System.Data;
System.Data.SqlClient;

public partial class register : System.Web.UI.Page
{
connection con = new connection();
protected void Page_Load(object sender, EventArgs e)
{
fillid();
}
public void fillid()
{
con.open_connection();
string str = "select * from registration order by userid";
SqlCommand cmd = new SqlCommand(str, con.con_pass());
SqlDataReader dr = cmd.ExecuteReader();
int i = 0;
while (dr.Read())
{
int a = 0;
a = Convert.ToInt32(dr["userid"].ToString());
ViewState["sid"] = a.ToString();
i = i + 1;
}
if (i > 0)
{
int a = Convert.ToInt32(ViewState["sid"].ToString());
a = a + 1;
txtID.Text = a.ToString();
}
else
txtID.Text ="101";
con.close_connection();
}
protected void Button1_Click1(object sender, EventArgs e)
{
try
{
if (txtEmail.Text == string.Empty)
{
Label9.Visible = true;
Label9.Text = "Email Must be Filled !!!!!";
}
if (txtcEmail.Text == string.Empty)

{

Label9.Visible = true;
Label9.Text = "Confirm Email Must be Filled !!!!!";

}
else if (txtFname.Text == string.Empty)
{
Label9.Visible = true;
Label9.Text = "First Name Must be Filled !!!!!";
}

else if (txtLName.Text == string.Empty)
{
Label9.Visible = true;
Label9.Text = "Last Name Must be Filled !!!!!";
}
else if (radGen.Text == string.Empty)
{
Label9.Visible = true;
Label9.Text = "Gender Must Must be selected !!!!!";
}
else if (txtPass.Text == string.Empty)
{
Label9.Visible = true;
Label9.Text = "Password Must be filled !!!!!";
}
else if (txtcPass.Text == string.Empty)
{
Label9.Visible = true;
Label9.Text = "Confirm Password Must be filled !!!!!";
}
else if (txtAdd.Text == string.Empty)
{
Label9.Visible = true;
Label9.Text = "Address Must be filled !!!!!";
}
else if (txtCity.Text == string.Empty)
{
Label9.Visible = true;
Label9.Text = "City Must be filled !!!!!";
}
else if (txtPone.Text == string.Empty)
{
Label9.Visible = true;
Label9.Text = "Phone Must be filled !!!!!";
}
else if (txtPostal.Text == string.Empty)
{
Label9.Visible = true;
Label9.Text = "Postal Code Must be filled !!!!!";
}
else
{
string st_status = "Active";
string st = "User";
con.open_connection();
string str = "insert into registration values('" + txtID.Text + "','" + txtEmail.Text + "','"
+ txtFname.Text + "','" + txtLName.Text + "','" + radGen.Text + "','" + txtFather.Text + "','" +
txtPass.Text + "','" + TextBox1.Text.Trim() + "','" + txtAdd.Text + "','" + txtCity.Text + "','" +

txtState.Text + "','" + txtPostal.Text + "','" + txtCountry.Text + "','" + txtPone.Text + "','" +
System.DateTime.Now.ToString() + "','" + st_status +
"','"+DropDownList1.SelectedValue+"','"+DropDownList2.SelectedValue+"')";
SqlCommand cmd = new SqlCommand(str, con.con_pass());
cmd.ExecuteNonQuery();
con.close_connection();
con.open_connection();
string str1 = "insert into login values('" + txtEmail.Text + "','" + txtPass.Text +
"','"+st+"')";
SqlCommand cmd1 = new SqlCommand(str, con.con_pass());
cmd1.ExecuteNonQuery();
con.close_connection();
Label9.Visible = true;
Label9.Text = "!!..Hi.." + txtFname.Text + " " + txtLName.Text + "', Your Account is
successfully created..!!";
}
}
catch (Exception ex)
{
Label9.Visible = true;
Label9.Text = ex.Message;
}
}

}

Connection
using
using
using
using
using
using
using
using
using
using
using
using

System;
System.Data;
System.Configuration;
System.Linq;
System.Web;
System.Web.Security;
System.Web.UI;
System.Web.UI.HtmlControls;
System.Web.UI.WebControls;
System.Web.UI.WebControls.WebParts;
System.Xml.Linq;
System.Data.SqlClient;

public class connection
{
SqlConnection conn;
string get_connect =
System.Configuration.ConfigurationManager.ConnectionStrings["ER"].ConnectionString;
public connection()
{
conn = new SqlConnection(get_connect);
}
public void open_connection()
{
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
}
public void close_connection()
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}

}

public SqlConnection con_pass()
{
return conn;
}

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close