I want the login form with the oops concepts in C# .Net.
I know this is a basic question, but I am not familiar with oops concepts.
I want the code to be writtten in classes and it is to be inherited in code
Can uplease help me to get the code
I tried the login form as below
Login.aspx
CODE
<table align="center" cellpadding="10">
<tr>
<td colspan="2" align="center">
<asp:Label runat="server" ID= "lbl_login" Text="Login Form" Font-Bold="True"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID= "lbl_username" Text="User Name" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txt_username" ></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID= "lbl_password" Text="Password" ></asp:Label>
</td>
<td>
<asp:TextBox runat="server" ID="txt_password" TextMode="Password" ></asp:TextBox>
</td>
</tr>
<tr>
<td align="center">
<asp:Button runat="server" ID="btn_login" Text="Login" OnClick="btn_login_Click" />
</td>
<td align="center">
<asp:Button runat="server" ID="btn_cancel" Text="Cancel" OnClick="btn_cancel_Click" />
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:Label ID="lbl_err" runat="server" Text="UserName and Password doesn't match" Font-Italic="True" ForeColor="DeepSkyBlue" Visible="False"></asp:Label></td>
</tr>
</table>
Login.aspx.cs
CODE
protected void btn_login_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("server=192.168.0.1;user id=practice1;password=teamwork;database=practice");
cn.Open();
SqlCommand cmd = new SqlCommand("select * from RamaLogin where UserName ='" + txt_username.Text + "' and Password='" + txt_password.Text + "' ", cn);
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.HasRows == true)
{
dr.Close();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataRow drt = ds.Tables[0].Rows[0];
string user = drt[0].ToString();
string password = drt[1].ToString();
if(user == txt_username.Text && password == txt_password.Text)
Response.Redirect("welcome.aspx?Name=" + this.txt_username.Text);
else
lbl_err.Visible = true;
}
else
{
lbl_err.Visible = true;
}
cn.Close();
}
Welcome.aspx
CODE
<table align="center" >
<tr>
<td>
<asp:Label runat="server" ID="lbl_welcome" Font-Bold="True" Font-Italic="True" Font-Size="16pt"></asp:Label>
</td>
</tr>
</table>
Welcome.aspx.cs
** Edit **