SlideShare a Scribd company logo
1 of 2
Download to read offline
Captcha Control by Salman Mushtaq
Web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="Practice" connectionString="Data Source=.;Initial
Catalog=Practice;Integrated Security=True"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
</system.web>
</configuration>
Mainform.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Recaptcha;
namespace ReCaptchaExample
{
public partial class MainForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblInsertMessage.Visible = false;
}
protected void btnInsert_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string name = txtName.Text.ToString();
CaptchaDataContext dbContext = new CaptchaDataContext();
Captcha cap = new Captcha();
cap.Name = name;
dbContext.Captchas.InsertOnSubmit(cap);
dbContext.SubmitChanges();
lblInsertMessage.Visible = true;
lblInsertMessage.Text = "Data Successfully entered";
}
else
{
lblInsertMessage.Visible = true;
lblInsertMessage.Text = "Invalid Captcha... Please re-enter.";
}
}
}
}
MainForm.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainForm.aspx.cs"
Inherits="ReCaptchaExample.MainForm" %>
<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="MainForm" runat="server">
<div>
<asp:Table runat="server">
<asp:TableRow runat="server">
<asp:TableCell runat="server"><asp:Label runat="server"
Text="Name:"></asp:Label></asp:TableCell>
<asp:TableCell runat="server"><asp:TextBox runat="server"
ID="txtName"></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">
<recaptcha:RecaptchaControl ID="recaptcha" runat="server"
PublicKey="Here you enter your public key which you find on Google
Recaptcha API’S"
PrivateKey="Here you enter your private key" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server"><asp:Button runat="server" ID="btnInsert"
OnClick="btnInsert_Click" Text="Insert Data" /></asp:TableCell>
<asp:TableCell runat="server"><asp:Label runat="server" ID="lblInsertMessage"
Text=""></asp:Label></asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</form>
</body>
</html>

More Related Content

What's hot

Exploring the details of APEX sessions
Exploring the details of APEX sessionsExploring the details of APEX sessions
Exploring the details of APEX sessionsMenno Hoogendijk
 
Api security-eic-prabath
Api security-eic-prabathApi security-eic-prabath
Api security-eic-prabathWSO2
 
Calling database with groovy in mule
Calling database with groovy in muleCalling database with groovy in mule
Calling database with groovy in muleAnirban Sen Chowdhary
 
Mule with spring security manager
Mule with spring security managerMule with spring security manager
Mule with spring security managerSon Nguyen
 
NServiceBus_for_Admins
NServiceBus_for_AdminsNServiceBus_for_Admins
NServiceBus_for_AdminsAdam Fyles
 
SPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx WebpartSPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx WebpartJenkins NS
 
Web Application Firewall intro
Web Application Firewall introWeb Application Firewall intro
Web Application Firewall introRich Helton
 
Whats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix MeschbergerWhats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix Meschbergermfrancis
 
TESTED
TESTEDTESTED
TESTEDsiryi
 
Stefaan Ponnet, Fusebox
Stefaan Ponnet, FuseboxStefaan Ponnet, Fusebox
Stefaan Ponnet, Fuseboxnascomgenk
 
MS LAPS protection: portal for secure access to local admin passwords
MS LAPS protection: portal for secure access to local admin passwordsMS LAPS protection: portal for secure access to local admin passwords
MS LAPS protection: portal for secure access to local admin passwordsNikolay Klendar
 
Felix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureFelix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureMarcel Offermans
 
Microsoft LAPS - Local Administrator Password Solution
Microsoft LAPS - Local Administrator Password SolutionMicrosoft LAPS - Local Administrator Password Solution
Microsoft LAPS - Local Administrator Password SolutionInt64 Software Ltd
 

What's hot (18)

Mule security-jaas
Mule security-jaasMule security-jaas
Mule security-jaas
 
Exploring the details of APEX sessions
Exploring the details of APEX sessionsExploring the details of APEX sessions
Exploring the details of APEX sessions
 
Api security-eic-prabath
Api security-eic-prabathApi security-eic-prabath
Api security-eic-prabath
 
Web api
Web apiWeb api
Web api
 
Calling database with groovy in mule
Calling database with groovy in muleCalling database with groovy in mule
Calling database with groovy in mule
 
Mule with spring security manager
Mule with spring security managerMule with spring security manager
Mule with spring security manager
 
Oip presentation
Oip presentationOip presentation
Oip presentation
 
NServiceBus_for_Admins
NServiceBus_for_AdminsNServiceBus_for_Admins
NServiceBus_for_Admins
 
SPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx WebpartSPFx Webinar Loading SharePoint data in a SPFx Webpart
SPFx Webinar Loading SharePoint data in a SPFx Webpart
 
Web api
Web apiWeb api
Web api
 
Web Application Firewall intro
Web Application Firewall introWeb Application Firewall intro
Web Application Firewall intro
 
Whats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix MeschbergerWhats New in the Http Service Specification - Felix Meschberger
Whats New in the Http Service Specification - Felix Meschberger
 
TESTED
TESTEDTESTED
TESTED
 
Stefaan Ponnet, Fusebox
Stefaan Ponnet, FuseboxStefaan Ponnet, Fusebox
Stefaan Ponnet, Fusebox
 
CakePHP REST Plugin
CakePHP REST PluginCakePHP REST Plugin
CakePHP REST Plugin
 
MS LAPS protection: portal for secure access to local admin passwords
MS LAPS protection: portal for secure access to local admin passwordsMS LAPS protection: portal for secure access to local admin passwords
MS LAPS protection: portal for secure access to local admin passwords
 
Felix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the futureFelix HTTP - Paving the road to the future
Felix HTTP - Paving the road to the future
 
Microsoft LAPS - Local Administrator Password Solution
Microsoft LAPS - Local Administrator Password SolutionMicrosoft LAPS - Local Administrator Password Solution
Microsoft LAPS - Local Administrator Password Solution
 

Similar to Captcha

Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0py_sunil
 
Web application using c# Lab - Web Configuration file
Web application using c# Lab - Web Configuration fileWeb application using c# Lab - Web Configuration file
Web application using c# Lab - Web Configuration filepriya Nithya
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 
Aspnet 4 new features
Aspnet 4 new featuresAspnet 4 new features
Aspnet 4 new featuresErkan BALABAN
 
QuickConnect
QuickConnectQuickConnect
QuickConnectAnnu G
 
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015gmaran23
 
การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
การเข ยนโปรแกรมต ดต_อฐานข_อม_ลการเข ยนโปรแกรมต ดต_อฐานข_อม_ล
การเข ยนโปรแกรมต ดต_อฐานข_อม_ลBongza Naruk
 
Java Web Application Security with Java EE, Spring Security and Apache Shiro ...
Java Web Application Security with Java EE, Spring Security and Apache Shiro ...Java Web Application Security with Java EE, Spring Security and Apache Shiro ...
Java Web Application Security with Java EE, Spring Security and Apache Shiro ...Matt Raible
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questionsAkhil Mittal
 
WebAppSec Updates from W3C
WebAppSec Updates from W3CWebAppSec Updates from W3C
WebAppSec Updates from W3CNatasha Rooney
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011Arun Gupta
 
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...Uniface
 
State management in ASP.NET
State management in ASP.NETState management in ASP.NET
State management in ASP.NETOm Vikram Thapa
 
JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンharuki ueno
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with SpringJoshua Long
 

Similar to Captcha (20)

Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0Whats new in ASP.NET 4.0
Whats new in ASP.NET 4.0
 
Web application using c# Lab - Web Configuration file
Web application using c# Lab - Web Configuration fileWeb application using c# Lab - Web Configuration file
Web application using c# Lab - Web Configuration file
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
Aspnet 4 new features
Aspnet 4 new featuresAspnet 4 new features
Aspnet 4 new features
 
QuickConnect
QuickConnectQuickConnect
QuickConnect
 
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015
Beefing Up Security In ASP.NET Dot Net Bangalore 3rd meet up on May 16 2015
 
Asp.net
Asp.netAsp.net
Asp.net
 
การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
การเข ยนโปรแกรมต ดต_อฐานข_อม_ลการเข ยนโปรแกรมต ดต_อฐานข_อม_ล
การเข ยนโปรแกรมต ดต_อฐานข_อม_ล
 
Java Web Application Security with Java EE, Spring Security and Apache Shiro ...
Java Web Application Security with Java EE, Spring Security and Apache Shiro ...Java Web Application Security with Java EE, Spring Security and Apache Shiro ...
Java Web Application Security with Java EE, Spring Security and Apache Shiro ...
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questions
 
Spring WebApplication development
Spring WebApplication developmentSpring WebApplication development
Spring WebApplication development
 
WebAppSec Updates from W3C
WebAppSec Updates from W3CWebAppSec Updates from W3C
WebAppSec Updates from W3C
 
JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
 
Servlet 3.0
Servlet 3.0Servlet 3.0
Servlet 3.0
 
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
Uniface Lectures Webinar - Building Responsive Applications with Uniface: Dev...
 
State management in ASP.NET
State management in ASP.NETState management in ASP.NET
State management in ASP.NET
 
JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオン
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 

More from Salman Mushtaq

More from Salman Mushtaq (7)

Bootstrap 3 Lecture 5
Bootstrap 3 Lecture 5Bootstrap 3 Lecture 5
Bootstrap 3 Lecture 5
 
LINQ to SQL
LINQ to SQLLINQ to SQL
LINQ to SQL
 
ADO DOT NET
ADO DOT NETADO DOT NET
ADO DOT NET
 
Contact Book Version 1.0
Contact Book Version 1.0Contact Book Version 1.0
Contact Book Version 1.0
 
Entity frame work by Salman Mushtaq -1-
Entity frame work by Salman Mushtaq -1-Entity frame work by Salman Mushtaq -1-
Entity frame work by Salman Mushtaq -1-
 
Database By Salman Mushtaq
Database By Salman MushtaqDatabase By Salman Mushtaq
Database By Salman Mushtaq
 
Serialization
SerializationSerialization
Serialization
 

Captcha

  • 1. Captcha Control by Salman Mushtaq Web.config <?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <connectionStrings> <add name="Practice" connectionString="Data Source=.;Initial Catalog=Practice;Integrated Security=True"/> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.5.1" /> <httpRuntime targetFramework="4.5.1" /> </system.web> </configuration> Mainform.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Recaptcha; namespace ReCaptchaExample { public partial class MainForm : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { lblInsertMessage.Visible = false; } protected void btnInsert_Click(object sender, EventArgs e) { if (Page.IsValid) { string name = txtName.Text.ToString(); CaptchaDataContext dbContext = new CaptchaDataContext(); Captcha cap = new Captcha(); cap.Name = name; dbContext.Captchas.InsertOnSubmit(cap); dbContext.SubmitChanges(); lblInsertMessage.Visible = true; lblInsertMessage.Text = "Data Successfully entered"; } else
  • 2. { lblInsertMessage.Visible = true; lblInsertMessage.Text = "Invalid Captcha... Please re-enter."; } } } } MainForm.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MainForm.aspx.cs" Inherits="ReCaptchaExample.MainForm" %> <%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="MainForm" runat="server"> <div> <asp:Table runat="server"> <asp:TableRow runat="server"> <asp:TableCell runat="server"><asp:Label runat="server" Text="Name:"></asp:Label></asp:TableCell> <asp:TableCell runat="server"><asp:TextBox runat="server" ID="txtName"></asp:TextBox></asp:TableCell> </asp:TableRow> <asp:TableRow runat="server"> <asp:TableCell runat="server"> <recaptcha:RecaptchaControl ID="recaptcha" runat="server" PublicKey="Here you enter your public key which you find on Google Recaptcha API’S" PrivateKey="Here you enter your private key" /> </asp:TableCell> </asp:TableRow> <asp:TableRow runat="server"> <asp:TableCell runat="server"><asp:Button runat="server" ID="btnInsert" OnClick="btnInsert_Click" Text="Insert Data" /></asp:TableCell> <asp:TableCell runat="server"><asp:Label runat="server" ID="lblInsertMessage" Text=""></asp:Label></asp:TableCell> </asp:TableRow> </asp:Table> </div> </form> </body> </html>