Description:
In the last article I have explained Auto refresh data in Gridview without loading page whole page in asp.net, How to use SiteMapPath Navigation Control in Asp.net, Encrypt and Decrypt Query String in asp.net, Create multiple Language website in Asp.net and Store Password in Encrypted format to Database in asp.net.
In the last article I have explained Auto refresh data in Gridview without loading page whole page in asp.net, How to use SiteMapPath Navigation Control in Asp.net, Encrypt and Decrypt Query String in asp.net, Create multiple Language website in Asp.net and Store Password in Encrypted format to Database in asp.net.
Captcha is mostly used in Sign up and contact us form. I use
the Recaptcha library. You can download the Recaptcha library from given link:
After download the Recapctha library extract it. You see the
option dll for 4.0 or 4.5 frameworks. Take new website, right click on your
website and choose Add Reference as shown in snapshot:
Now click on browse and select the Recaptcha.web.dll.
You
can also add the Captcha control to Toolbox. To use Captcha control you need a
public and private key. To get the key go to below given link:
Here you are asking for login. Login with your Google/Gmail
account. After login you are redirect to create captcha key, enter your domain
(e.g. articlemirror.blogspot.in)
and select the checkbox to use this on all domains. After that click on Create
key button. You have done it. You see a page as shown below:
Now add the key in web.config file:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<appSettings>
<add key="recaptchaPublicKey" value="Public key"/>
<add key="recaptchaPrivateKey" value="Private key"/>
</appSettings>
</configuration>
Add a new webform to website. Register the control on your
.aspx page add the following:
<%@ Register
Assembly="Recaptcha.Web"
Namespace="Recaptcha.Web.UI.Controls"
TagPrefix="cc1"
%>
If you added the control in toolbox than drag and drop it to
page. If not added to toolbox than add the following to page:
<cc1:Recaptcha ID="Recaptcha" runat="server" />
Design the page.aspx as
mention below:
<form id="form1" runat="server">
<div>
<table align="center"><tr><td>
<cc1:Recaptcha ID="Recaptcha"
runat="server"
/></td><td><asp:Label ID="Label1" runat="server"
Text=""></asp:Label></td></tr>
<tr><td>
<asp:Button ID="btncaptcha"
runat="server"
Text="Confirm"
onclick="btncaptcha_Click"
/>
</td></tr></table>
</div>
</form>
On button click write the given code (.aspx.cs) :
using Recaptcha.Web;
protected void
btncaptcha_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(Recaptcha.Response))
{
Label1.Text = "Captcha cannot be
empty.";
}
else
{
RecaptchaVerificationResult verify =
Recaptcha.Verify();
if (verify == RecaptchaVerificationResult.Success)
{
Label1.Text = "Captcha Match";
}
else
{
Label1.Text = "Captcha information not
matched";
}
}
}
In VB (.aspx.vb) :
Imports Recaptcha.Web
Protected Sub
btncaptcha_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
btncaptcha.Click
If String.IsNullOrEmpty(Recaptcha.Response)
Then
Label1.Text = "Captcha cannot be
empty."
Else
Dim verify As RecaptchaVerificationResult = Recaptcha.Verify()
If verify = RecaptchaVerificationResult.Success
Then
Label1.Text = "Captcha Match"
Else
Label1.Text = "Captcha information not
matched"
End If
End If
End Sub
Now run the project and checked out the result.
WOW just what I was looking for. Came here by searching for business services
ReplyDeleteFeel free to surf to my web page; Life advice (myfotowiki.de)
Hmm is anyone else encountering problems with the pictures on this blog loading?
ReplyDeleteI'm trying to determine if its a problem on my end or if it's
the blog. Any feedback would be greatly appreciated.
My web blog: online shopping
Hi, everything is going perfectly here and ofcourse every one is sharing facts, that's genuinely excellent, keep up writing.
ReplyDeleteMy site; business advice ()
good articleFountechbd
ReplyDeletethanks......keep reading
DeleteThanks :)!!!
ReplyDeleteyou are always welcomed......keep visiting.......
Delete