Adding Captcha to CreateUserWizard

bharanidharanit

Well-known member
Joined
Dec 8, 2008
Messages
53
Location
India
Programming Experience
1-3
Hello,
I am using Visual Web Developer 2008.
I added CreateUserWizard on the form. In the CreateUserWizard Control, I want to add Captcha Control. And how can i do this?
Thankyou
 
Captcha

Hello,
I am using Visual Web Developer 2008.
I added CreateUserWizard on the form. In the CreateUserWizard Control, I want to add Captcha Control. And how can i do this?
Thankyou

There is no easy answer to this and it takes time and work. First you'll either need to create images of letters or/and number. The other opiton is coding the letters and/or numbers into your code in either VB or C# or some other web compatible language.

Then you need to have some code for the images or the generator. I use images and code to generate the captcha.

Here is some code for numbers. Take into count you NEED to have the image file in the "images/numbers/" folder in the project when you test this.

CODE --------------------------------- Start
<%@ Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="ASP_Captcha_VB2008._Default" %>

<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
Dim strCaptcha As String
Dim strNumber, strChar, strChar1, strChar2 As String
Dim intCount As Integer
strChar = "0123456789"
strChar1 = "abcdefghijklmnopqrstuvwxyz"
strChar2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
intCount = Len(strChar)

Randomize
For i = 1 To 5
strNumber = Mid(strChar1, 1 + Int(Rnd() * intCount), 1)
strCaptcha = strCaptcha & strNumber
Response.Write("<img src='images/AlphaLower/" & strNumber & ".gif' />")
Next
session("captcha")=strCaptcha
%>
</div>
</form>
</body>
</html>
CODE ---------------------------------------- END

This code is a single ASPX page that just generates UPPER Letter, lower letters, or numbers currently. You will also need a validation script or code to verify what the user inputs is the image.

Notice the code calling the letters in Mid(strChar1, string. You could very easily call strChar and it would render the numbers 0-9 randomly or strChar2 and it will use lower case letter. You could also combine all three and have your captcha generate random UPPER, lower and Numbers in the image.

Also note the location of the "img src-'images/AlphaLower/" & in the Response.Write line. This is the folder for the images.
 
Back
Top