Login Only Allow 3 Attempt
If User Use Login Control Three Attempts Failures After That Lock The Login All Control Using In Asp.Net C#.
DEMO
HTML CODING
C# CODING
Next - Login Button Select - Write Below Coding
Next - Set The Intervel Time - If Start Timer Lock The Button & TextBoxes
If Timer TimeOut Enable The All Textboxes & Buttons
Next - Run[F5] The Program - Starting Count = 0 When count =4 Timer Will Start Controls Lock
If User Use Login Control Three Attempts Failures After That Lock The Login All Control Using In Asp.Net C#.
DEMO
HTML CODING
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var Time = 60, check = null;
function Assigninterval() {
// One
Second Set
check = setInterval(starttimer,
1000);
}
function starttimer() {
Time -= 1;
var Element = document.getElementById("Text11");
Element.style.color = "red";
document.getElementById("Style11").innerHTML
= "Your Time Left: " + Time;
if (Time <= 0) {
clearInterval(check);
check = null;
Time = 0;
document.getElementById("Style11").innerHTML
= '';
document.getElementById("txtLoginCount").readOnly
= false;
document.getElementById("txtUsername").readOnly
= false;
document.getElementById("txtPassword").readOnly
= false;
document.getElementById('<%= Login1.ClientID %>').disabled = false;
}
else {
document.getElementById("txtLoginCount").readOnly
= true;
document.getElementById("txtUsername").readOnly
= true;
document.getElementById("txtPassword").readOnly
= true;
document.getElementById('<%= Login1.ClientID %>').disabled = true;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="Text11">
<p id="Style11" style="font:bold 24px caption"></p>
</div>
<div id ="loc">
<table><tr><td>
<asp:Label ID="Label1" runat="server" Text="Login
Count"></asp:Label>
</td><td>
<asp:TextBox ID="txtLoginCount" runat="server">0</asp:TextBox>
</td></tr>
<tr><td>
<asp:Label ID="Label2" runat="server" Text="Username"></asp:Label>
</td><td>
<asp:TextBox ID="txtUsername" runat="server"></asp:TextBox>
</td></tr>
<tr><td>
<asp:Label ID="Label3" runat="server" Text="Password"></asp:Label>
</td><td>
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
</td></tr>
<tr><td></td><td>
<asp:Button ID="Login1" runat="server" OnClick="LoginButton_Click1" Text="Login" Height="26px" Width="76px" />
</td></tr>
</table>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LoginButton_Click1(object sender, EventArgs e)
{
if (txtUsername.Text == "A" && txtUsername.Text == "A")
{
Response.Write("OK");
}
else
{
int count = 1;
txtLoginCount.Text = (count + Convert.ToInt32(txtLoginCount.Text)).ToString();
if (Convert.ToInt32(txtLoginCount.Text) > 3)
{
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page,
typeof(Page), "Script", "Assigninterval();", true);
txtLoginCount.Text = "0";
}
else
{
Response.Write(" Invalid Username or Password");
}
}
}
}
First - Add The New Web Form - Select The TextBoxes & Buttons - Login Count TextBox Text=0
Next - Login Button Select - Write Below Coding
Next - Set The Intervel Time - If Start Timer Lock The Button & TextBoxes
If Timer TimeOut Enable The All Textboxes & Buttons
Next - Run[F5] The Program - Starting Count = 0 When count =4 Timer Will Start Controls Lock
ReplyDeleteSuch a great blog.Thanks for sharing useful information......
Javascript training in bangalore
Javascript course in bangalore