Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > Captcha Creation In Vb.net

Reply
Thread Tools

Captcha Creation In Vb.net

 
 
cutekiller28 cutekiller28 is offline
Junior Member
Join Date: Sep 2008
Posts: 4
 
      09-22-2008
Hello frens
i wanted to create a captcha for my project in vb.net could anybody help me with a code how to create it ....rest i have created a way in which the page main form call this image which doesnt exist formally but it calls my this page jpegimage.vb to get its image but i m still having problems in the session genrated part i hope so .the code is below of main page and the jpegimage.aspx page
===========
main form
==========

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Namespace CaptchaImage
Public Class _Default
Inherits System.Web.UI.Page

Protected Label1 As System.Web.UI.WebControls.Label
Protected WithEvents CodeNumberTextBox As System.Web.UI.WebControls.TextBox

Protected WithEvents IMG1 As System.Web.UI.HtmlControls.HtmlImage
Protected WithEvents tb1 As System.Web.UI.WebControls.TextBox
Protected WithEvents SubmitButton As System.Web.UI.WebControls.Button
' For generating random numbers.
Private random As New Random

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

If Not Me.IsPostBack Then
Session("CaptchaImageText") = GenerateRandomCode()
Else

' Create a random code and store it in the Session object.

' On a postback, check the user input.
If Me.CodeNumberTextBox.Text = Session("CaptchaImageText").ToString() Then
' Display an informational message.
Me.Label1.CssClass = "info"
Me.Label1.Text = "Correct!"
Else
' Display an error message.
Me.Label1.CssClass = "error"
Me.Label1.Text = "ERROR: Incorrect, try again."

' Clear the input and create a new random code.
Me.CodeNumberTextBox.Text = ""
Me.Session("CaptchaImageText") = GenerateRandomCode()
End If
End If
End Sub


'
' Returns a string of six random digits.
'
Private Function GenerateRandomCode() As String


Dim s As String = ""
For i As Integer = 0 To 7
s = [String].Concat(s, Me.random.[Next](10).ToString())
Next
Return s
End Function

#Region "Web Form Designer generated code"
Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
'
' CODEGEN: This call is required by the ASP.NET Web Form Designer.
'
InitializeComponent()
MyBase.OnInit(e)
End Sub

''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>
Private Sub InitializeComponent()

End Sub
#End Region
End Class
End Namespace

=========
jpegimage form
========
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Namespace CaptchaImage
Public Class JpegImage
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
' Create a CAPTCHA image using the text stored in the Session object.
Dim ci As New CaptchaImage(Session("CaptchaImageText").ToString( ), 200, 50, "Scrawl")
'me. removed
' Change the response headers to output a JPEG image.
Me.Response.Clear()
Me.Response.ContentType = "image/jpeg"

' Write the image to the response stream in JPEG format.
ci.Image.Save(Me.Response.OutputStream, ImageFormat.Jpeg)

' Dispose of the CAPTCHA image object.

Session("CaptchaImageText").Dispose()
End Sub

#Region "Web Form Designer generated code"
Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
'
' CODEGEN: This call is required by the ASP.NET Web Form Designer.
'
InitializeComponent()
MyBase.OnInit(e)
End Sub

''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>
Private Sub InitializeComponent()
AddHandler Me.Load, AddressOf Page_Load
End Sub
#End Region
End Class
End Namespace


==========
please see to it if u could help me out its urgent to be done ..Thanks in advance
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Captcha : Zero Dependecy Captcha for Rails sur Ruby 0 12-23-2007 03:05 AM
How to (batch) set EXIF date taken and IPTC creation date and creation time for photos with filenames YYMMDDHHMMSS#.jpg? guercheLE@gmail.com Digital Photography 1 10-04-2005 07:15 PM
Capturing Text from CAPTCHA Images Krishna Kumar ASP .Net 6 08-05-2005 01:22 PM
Captcha Images prasad ASP .Net 1 04-28-2005 02:22 AM
Captcha Peter Morn Java 0 12-16-2004 10:58 AM



Advertisments