Example of how to add captcha in Asp.net using C#
How to add captcha in Asp.net programming :
In this post we see How to add captcha in asp.net add captcha in Asp.net web site :As we know that the captcha use for check the access by the human.it is use to make retraction for accessing web site or web pages by the automatically by software.
So we describe some simple steps :
Step 1: Make a new web site
how to add capcha in Asp.net programming |
b.)Go to file
menu and click,
c.)Go to web
application ->new web site
d.) After
opening window give the name of web site.
e.) Download
capcha dll from fallowing links. As you wish.
Download Dll file for Captcha
Step 2: Add dll file in to web site.
a.)Go to
Solution Explorer-> right click on web site name .
b.)Make bin folder
for adding .ddl files and .cs files ;
c.)again
click on web site name and add reference of dll files .
step 3: make a web page
a.)
Right click on web site name and add new item
->select web page ->the open
b.)
Now in this web page Wright given code
.
Code for .aspx page
<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default"
%>
<%@ Register Assembly="MSCaptcha"
Namespace="MSCaptcha"
TagPrefix="cc1"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="S_Contact">
<h2 class="S_Heading">
Chapcha Demo</h2>
<div class="row">
<label>
<p>
Full Name*
</p>
</label>
<asp:TextBox ID="txtFName" runat="server"></asp:TextBox>
</div>
<div class="row">
<label>
<p>
Applyed For*
</p>
</label>
<asp:TextBox ID="txtApplicationFor" runat="server"></asp:TextBox>
</div>
<div class="row">
<label>
<p>
Email*
</p>
</label>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="regValidator" runat="server" ErrorMessage="Email is not vaild."
ForeColor="Red" ControlToValidate="txtEmail" ValidationExpression="^\s*(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+([;.](([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}){1,25})+)*\s*$"
ValidationGroup="a" Font-Bold="True" Font-Size="10px">Email is not vaild.</asp:RegularExpressionValidator>
</div>
<div class="row">
<label>
<p>
Upload Resume*
</p>
</label>
<asp:FileUpload ID="FLUpload" runat="server" />
</div>
<div class="row">
<cc1:CaptchaControl ID="ccJoin" runat="server" CaptchaBackgroundNoise="none" CaptchaLength="5"
CaptchaHeight="40" CaptchaWidth="150" CaptchaLineNoise="None" CaptchaMinTimeout="5"
CaptchaMaxTimeout="140" FontColor="Red" Width="155px" />
<asp:TextBox ID="txtCaptcha" runat="server"></asp:TextBox>
</div>
<div class="row">
<asp:Button ID="btnSave" runat="server" class="S_Btn cursor" Style="margin-right: 10px;"
Text="Submit" onclick="btnSave_Click" /><%--ValidationGroup="a"--%>
</div>
<div class="row">
<asp:Label ID="lblMsg" runat="server" Visible="False" ForeColor="Red" Font-Bold="true"
Font-Size="12px"></asp:Label>
</div>
</div>
</div>
</form>
</body>
</html>
Code for aspx.cs page :
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object
sender, EventArgs e)
{
}
protected void btnSave_Click(object
sender, EventArgs e)
{
ccJoin.ValidateCaptcha(txtCaptcha.Text);
if
(!ccJoin.UserValidated)
{
lblMsg.Visible = true;
lblMsg.Text = "Invalid Text. Try Again!";
return;
//Inform user that his input was wrong ...
}
else
{
}
}
}
Thank you ..
Other Asp.net related post :
- Cloud Service Provider
- Asp.net Label control
- Textbox Asp.net control
- Print pdf file in asp.net by C sharp
- SQL Server questions for interview
- Check box in ASP.NET GridView
- Ckeck box list example-using-javascript.
- Asp.net web api in asp.net programming
- How to achieve many selection in dropdownlist.
- Example of use of compare validator in asp.net.
- Find datetime difference in asp.net by C#
- Validation checkbox control using JavaScript
- Use of Viewstate in asp.net programming.
- How to add reference of dll file in asp.net.
- How to print div in asp.net programming
- Data base connection in asp.net in web Application
- Validate ASP.Net RadioButtonList using JavaScript Example
- Events in asp.net server controls how to handle in C#.
- Add rows in GridView dynamic with Textbox
- Asp.net Watermark Text on uploaded Image
- Asp.net NullReferenceException and how fix it
- State Management and type of State Management
- Cookies,how to make Cookies in asp.net with C#.
- Jquery Change div background on mouseover in asp.net
- In asp.net by jquery change div text color on mouseover
- Upload multiple by one asp.net fileupload control using jQuery
- Adding Dynamic Rows in ASP.Net GridView Control with Textbox
- In Asp.net Difference between ""(empty string) and String.Empty
Dropdownlist Related Post:
- Bind Dropdown by Dynamically
- Checkbox in asp Dropdown List.
- Fill Dropdown By database.
- Display Selected Date
- DropDown List in asp.net Programming,
- Drop Down List control of asp.net
- Add ListItem in DropDownList asp.net c# Example
- Single select option to the user from many items.
- Example of Adding ToolTip for each Dropdown List Item
- Bind Dropdown by Dynamically
- Checkbox in asp Dropdown List.
- Fill Dropdown By database.
- Display Selected Date
- DropDown List in asp.net Programming,
- Drop Down List control of asp.net
- Add ListItem in DropDownList asp.net c# Example
- Single select option to the user from many items.
- Example of Adding ToolTip for each Dropdown List Item