Create Login Page in Asp.Net Using C#. Designing side of login page using asp.net C# . Creating a login page in any project is the main milestone. login page is the entry point of every project. here is complete coding of creating login page in asp.net using C# language using visual studio.
<table align=”center” cellpadding=”3″ cellspacing=”5″ style=”width: 70%”> <tr>
<td class=”h40″ colspan=”2″ style=”height: 31px”> <h1> <asp:Label ID=”Label1″ runat=”server” ForeColor=”Black” Text=”User Login” Font-Names=”Times New Roman”></asp:Label>
</h1> </td> </tr>
<tr> <td style=”width: 166px; text-align: right;”> <asp:Label runat=”server” Text=”User ID” Font-Bold=”True” Font-Names=”Times New Roman” Font-Size=”15pt” ID=”Label4″></asp:Label> </td>
<td class=”col_w420″ style=”width: 450px”> <asp:TextBox ID=”txt_userID” runat=”server” Width=”200px” Height=”20px”></asp:TextBox> <asp:RegularExpressionValidator ID=”RegularExpressionValidator1″ runat=”server” ControlToValidate=”txt_userID” ErrorMessage=”Formate error” ValidationExpression=”\w+([-+.’]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*”></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator2″ runat=”server” ErrorMessage=”Plz Enter Email Address” ControlToValidate=”txt_userID”></asp:RequiredFieldValidator> </td> </tr> <tr>
<td style=”width: 166px; text-align: right;”> <asp:Label runat=”server” Text=”Password” Font-Bold=”True” Font-Names=”Times New Roman” Font-Size=”15pt” ID=”Label5″></asp:Label> </td>
<td class=”col_w420″ style=”width: 450px”> <asp:TextBox ID=”txt_password” runat=”server” Width=”200px” TextMode=”Password” Height=”20px”></asp:TextBox>
<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ErrorMessage=” Plz Enter Password” ControlToValidate=”txt_password”></asp:RequiredFieldValidator> </td> </tr> <tr>
<td style=”width: 166px; text-align: right;”> </td> <td class=”col_w420″ style=”width: 450px”> <asp:CheckBox ID=”CheckBox1″ runat=”server” Text=”Remember me” /> </td> </tr> <tr>
<td style=”width: 166px; text-align: right;”> </td>
<td class=”col_w420″ style=”width: 450px”>
<asp:Button ID=”btn_login” class=”btn btn-primary” runat=”server” Font-Names=”Times New Roman” Font-Size=”11pt” OnClick=”btn_login_Click” Text=”Login” Width=”100px” />
</td> </tr>
<tr>
<td style=”width: 166px; text-align: right;”> </td>
<td class=”col_w420″ style=”width: 450px”>
<a href=”personalDetails.aspx”>Creat New Candidate Account.</a></td></tr></table>

Coding side of How to create Login Page in asp.net
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.Sql; using System.Data.SqlClient; public partial class login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btn_login_Click(object sender, EventArgs e) { String str = System.Configuration.ConfigurationManager.ConnectionStrings["con_str"].ConnectionString; SqlConnection con = new SqlConnection(str); SqlCommand cmd = new SqlCommand(); con.Open(); cmd.Connection = con; cmd.CommandText = "select * from CDetails where c_email='" + txt_userID.Text + "' and password ='" + txt_password.Text + "' "; SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Session["candidate_id"] = reader["candidate_id"].ToString(); Session["c_email"] = reader["c_email"].ToString(); Session["login"] = "yes"; Response.Redirect("newUserAccount.aspx?candidate_id=" + reader["candidate_id"].ToString() + ""); } } else { Response.Write("Login failed"); } }
}