Sunday, April 4, 2010

SPAM BLOCKER CAPTCHA SOURCE CODE DOWNLOAD IN ASP.NET AND VB.NET

“SPAM BLOCKER CAPTCHA” is a program that protects websites against bots by generating and grading tests that humans can pass but current computer programs cannot.

TO DOWNLOAD THIS SOFTWARE CLICK HERE

“SPAMBLOCKER.ASPX”

<%@ Page Language="vb" AutoEventWireup="false" Inherits="ValidationCodeImage.DemoForm" CodeFile="spamblocker.aspx.vb" %>

DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<title>SPAM BLOCKER - CAPTCHAtitle>

<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">

<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">

<meta name="vs_defaultClientScript" content="JavaScript">

<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">

HEAD>

<body>

<form id="Form1" method="post" runat="server">

<asp:Label id="titlelabel" runat="server" Style="z-index:120px;top:18px;left:188px;position:absolute " Font-Bold ="true" ForeColor ="SpringGreen" Font-Size ="XX-Large" >SPAM BLOCKER - CAPTCHAasp:Label>

<asp:Image id="imgValidation" runat="server" ImageUrl="ValidationImage.aspx" Style="z-index:120px;top:207px;left:369px;position:absolute " Height="61px" Width="300px">asp:Image>

<asp:Label id="lblMessage" runat="server" Style="z-index:120px;top:287px;left:394px;position:absolute ">Please Enter the code that you see above:asp:Label>

<asp:TextBox id="txtCode" runat="server" Style="z-index:120px;top:315px;left:440px;position:absolute " TabIndex="3">asp:TextBox>

<asp:Button id="btnOK" runat="server" Text="OK" Style="z-index:120px;top:348px;left:479px;position:absolute " Width ="80" TabIndex="4" >asp:Button>

<asp:Label id="Label1" runat="server" Style="z-index:120px;top:500px;left:50px;position:absolute " ForeColor ="BlueViolet" >SPAM BLOCKER - CAPTCHA - DEVELOPED BY STUDENTasp:Label>

<asp:Label ID="Label2" runat="server" Style="left: 359px; position: absolute; top: 163px">Enter Your Last Nameasp:Label>

<asp:Label ID="Label3" runat="server" Style="left: 358px; position: absolute; top: 130px">Enter Your First Nameasp:Label>

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="textbox2" runat="server" ErrorMessage="RequiredFieldValidator" Text="*" style="z-index :120px; top:126px;left:690px; position :absolute "> asp:RequiredFieldValidator>

<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="textbox1" runat="server" ErrorMessage="RequiredFieldValidator" Text="*" style="z-index :120px; top:159px;left:690px; position :absolute "> asp:RequiredFieldValidator>

<asp:TextBox ID="TextBox1" runat="server" Style="left: 524px; position: absolute;

top: 162px" TabIndex="2">asp:TextBox>

<asp:TextBox ID="TextBox2" runat="server" Style="left: 524px; position: absolute;

top: 127px" TabIndex="1">asp:TextBox>

form>

body>

HTML>

“SPAMBLOCKER.ASPX.VB”

Option Explicit On

Option Strict On

Namespace ValidationCodeImage

Partial Class DemoForm

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load

txtCode.Focus()

'Put user code to initialize the page here

End Sub

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

' make sure session variable exists

If Session("Validation") Is Nothing Then

lblMessage.Text = "Session Not Validated.Try again by refreshing your browser"

Return

End If

' if end-user matched correctly

If Me.txtCode.Text = Session("Validation").ToString Then

' notify of success

lblMessage.ForeColor = Color.Green

lblMessage.Font.Size = 30

Label3.Text = "Welcome " + TextBox2.Text + " " + TextBox1.Text + ""

lblMessage.Text = "You are a human!"

' hide everything else

Label2.Visible = False

TextBox2.Visible = False

TextBox1.Visible = False

Me.imgValidation.Visible = False

Me.txtCode.Visible = False

Me.btnOK.Visible = False

Else

' display generic machine message as a joke

lblMessage.ForeColor = Color.Red

lblMessage.Font.Size = 30

Label3.Text = "Welcome " + TextBox2.Text + " " + TextBox1.Text + ""

lblMessage.Text = "You are Spam"

Label2.Visible = False

TextBox2.Visible = False

TextBox1.Visible = False

Me.imgValidation.Visible = False

Me.txtCode.Visible = False

Me.btnOK.Visible = False

End If

End Sub

End Class

End Namespace

“VALIDATIONIMAGE.APSX”

<%@ Page Language="vb" AutoEventWireup="false" Inherits="ValidationCodeImage.ValidationImage" CodeFile="ValidationImage.aspx.vb" %>

DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<title>WebForm1title>

<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">

<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">

<meta content="JavaScript" name="vs_defaultClientScript">

<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

HEAD>

<body>

<form id="Form1" method="post" runat="server">

form>

body>

HTML>

“VALIDATIONIMAGE.ASPX.VB”

Option Explicit On

Option Strict On

Namespace ValidationCodeImage

Partial Class ValidationImage

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

Dim VCI As New ValidationCodeImage

Response.BinaryWrite(VCI.Render())

Session("Validation") = VCI.Text

End Sub

End Class

End Namespace




For Further Reading,
ASP .NET, SPAM BLOCKER, VB .NET

0 comments:

Post a Comment