Empowering The World Through Technology

Create Login Page in Asp.Net Using C#

Create Login Web page in Asp.Internet Utilizing C#. Designing aspect of login web page utilizing asp.internet C# . Making a login web page in any challenge is the principle milestone. login web page is the entry level of each challenge. right here is full coding of making login web page in asp.internet utilizing C# language utilizing visible studio.

<desk align=”heart” cellpadding=”3″ cellspacing=”5″ fashion=”width: 70%”>     <tr>

<td class=”h40″ colspan=”2″ fashion=”top: 31px”>                     <h1>                         <asp:Label ID=”Label1″ runat=”server” ForeColor=”Black” Textual content=”Consumer Login” Font-Names=”Occasions New Roman”></asp:Label>

                    </h1>                 </td>             </tr>

            <tr>                 <td fashion=”width: 166px; text-align: proper;”>                     <asp:Label runat=”server” Textual content=”Consumer ID” Font-Daring=”True” Font-Names=”Occasions New Roman” Font-Measurement=”15pt” ID=”Label4″></asp:Label>                     </td>

                <td class=”col_w420″ fashion=”width: 450px”>&nbsp;<asp:TextBox ID=”txt_userID” runat=”server” Width=”200px” Peak=”20px”></asp:TextBox> &nbsp;<asp:RegularExpressionValidator ID=”RegularExpressionValidator1″ runat=”server” ControlToValidate=”txt_userID” ErrorMessage=”Formate error” ValidationExpression=”w+([-+.’]w+)*@w+([-.]w+)*.w+([-.]w+)*”></asp:RegularExpressionValidator>

                    &nbsp;<asp:RequiredFieldValidator ID=”RequiredFieldValidator2″ runat=”server” ErrorMessage=”Plz Enter E-mail Handle” ControlToValidate=”txt_userID”></asp:RequiredFieldValidator>                 </td>             </tr>             <tr>

                <td fashion=”width: 166px; text-align: proper;”>                     <asp:Label runat=”server” Textual content=”Password” Font-Daring=”True” Font-Names=”Occasions New Roman” Font-Measurement=”15pt” ID=”Label5″></asp:Label>                     </td>

                <td class=”col_w420″ fashion=”width: 450px”>&nbsp;<asp:TextBox ID=”txt_password” runat=”server” Width=”200px” TextMode=”Password” Peak=”20px”></asp:TextBox>

&nbsp;<asp:RequiredFieldValidator ID=”RequiredFieldValidator1″ runat=”server” ErrorMessage=” Plz Enter Password” ControlToValidate=”txt_password”></asp:RequiredFieldValidator>                 </td>             </tr>             <tr>

                <td fashion=”width: 166px; text-align: proper;”>&nbsp;</td>                 <td class=”col_w420″ fashion=”width: 450px”>&nbsp;<asp:CheckBox ID=”CheckBox1″ runat=”server” Textual content=”Bear in mind me” /> &nbsp;</td>             </tr>             <tr>

Top Trending

                <td fashion=”width: 166px; text-align: proper;”>&nbsp;</td>

<td class=”col_w420″ fashion=”width: 450px”>&nbsp;

           <asp:Button ID=”btn_login” class=”btn btn-primary” runat=”server” Font-Names=”Occasions New Roman” Font-Measurement=”11pt” OnClick=”btn_login_Click” Textual content=”Login” Width=”100px” />&nbsp;

</td>           </tr>

<tr>

<td fashion=”width: 166px; text-align: proper;”>&nbsp;</td>

<td class=”col_w420″ fashion=”width: 450px”>

<a href=”personalDetails.aspx”>Creat New Candidate Account.</a></td></tr></desk>

Create Login Page in Asp.Net Using C#
Create Login Web page in Asp.Internet Utilizing C#

Coding aspect of Methods to create Login Web page in asp.internet

utilizing System;
utilizing System.Collections.Generic;
utilizing System.Linq;
utilizing System.Net;
utilizing System.Net.UI;
utilizing System.Net.UI.WebControls;
utilizing System.Information;
utilizing System.Information.Sql;
utilizing System.Information.SqlClient;
public partial class login : System.Net.UI.Web 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 = "choose * from CDetails the place c_email='" + txt_userID.Textual content + "' and password ='" + txt_password.Textual content + "' ";

    SqlDataReader reader = cmd.ExecuteReader();

    if (reader.HasRows)
    {
        whereas (reader.Learn())
        {
            Session["candidate_id"] = reader["candidate_id"].ToString();
            Session["c_email"] = reader["c_email"].ToString();

            Session["login"] = "sure";

            Response.Redirect("newUserAccount.aspx?candidate_id=" + reader["candidate_id"].ToString() + "");


        }
    }
    else
    {
        Response.Write("Login failed");
    }
}

}

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More