Help needed with simple login page with .net

Posted by White-Rabbit under C# on 10/8/2012 | Points: 10 | Views : 1204 | Status : [Member] | Replies : 4
Please help me to create a simple login page with oops concept.

I dont have any idea how to use oops here.Help is gratly appreciated.




Responses

Posted by: Ranjeet_8 on: 10/9/2012 [Member] [MVP] Gold | Points: 25
Posted by: Ranjeet_8 on: 10/10/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi.. @White-Rabbit
if this helps u please Mark As Answer.

White-Rabbit, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 10/10/2012 [Member] Starter | Points: 25

Up
0
Down
hi,
try this
http://www.aspdotnet-suresh.com/2011/12/how-to-create-simple-login-form-using.html

Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

White-Rabbit, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 10/11/2012 [Member] Bronze | Points: 25

Up
0
Down
Try this below code
Page Design
Javascript avlidations
<head runat="server">

<title>Login</title>
<script type="text/javascript" language="javascript">
function Validate()
{
var UName=document.getElementById('txtUName');
var Password=document.getElementById('txtPassword');
if((UName.value=='') || (Password.value==''))
{
alert('User Name or Password should not be blank');
return false;
}
else
{
return true;
}
}
</script>
</head>

Form Controls
 <form id="form1" runat="server">

<div align="center">
<h3>User Login</h3>
</div>
<table align="center">
<tr>
<td>
<asp:Label ID="lblUName" runat="server" Text="UserName"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtUName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblPassword" runat="server" Text="Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
</td>
</tr>
</table>
<div align="center">
<asp:Button ID="btnLogin" OnClientClick="Validate()" runat="server" Text="Login"
onclick="btnLogin_Click" />
</div>
</form>

Button Click Event
protected void btnLogin_Click(object sender, EventArgs e)

{
string UName = txtUName.Text.Trim();
string Pwd = txtPassword.Text.Trim();
SqlConnection cnn = new SqlConnection(Conn);
SqlDataAdapter ada = new SqlDataAdapter("select * from tbl_Login", cnn);
DataSet ds = new DataSet();
ada.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
if ((UName == ds.Tables[0].Rows[0]["UName"].ToString()) && (Pwd == ds.Tables[0].Rows[0]["Password"].ToString()))
{
ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Login Success');", true);
}
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Login Failed');", true);
}
}


Join Hands Change lives
Thanks & Regards
Straight Edge Society

White-Rabbit, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response