Hi sir,
Tell me the steps to create a captcha image in asp.net c# using System.Drawing. I have a code to generate captcha text, but i need to display as image to the user instead of displaying in label or textbox. Kindly give me the solution for this problem.
[Hint: Need code to draw a text image using System.Drawing. Suppose if i pass the text as "Ky9f8" it will draw the corresponding image draw]
Loading

Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 11, 2013, 11:02 PM EDT
refer to this link
http://www.codeproject.com/Articles/169371/Captcha-Image-using-C-in-ASP-NET
http://www.codeproject.com/Articles/99148/Simple-CAPTCHA-Create-your-own-in-C
Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 12, 2013, 12:31 AM EDT
Suthish NairRank #92 · 22.8K reputationPosted Sep 13, 2013, 2:28 AM EDT
Aswini Aluri2 reputationPosted Nov 14, 2013, 1:23 AM EST
captcha image
Width="148px" Height="33px">
Width="30px" Height="30px" AlternateText="refresh"
onclick="ImageButton1_Click" />
onclick="ImageButton2_Click"/>
ErrorMessage="Please enter correct Text" ForeColor="Red">
In .aspx.cs page:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
StringBuilder builder = new StringBuilder();
builder.Append(RandomNumber(10, 99));
builder.Append(RandomString(3, true));
builder.Append(RandomString(2, false));
txtrobocomp.Text = builder.ToString();
}
}
private int RandomNumber(int min, int max)
{
Random rd = new Random();
return rd.Next(min, max);
}
private string RandomString(int size, bool lowerCase)
{
StringBuilder builder = new StringBuilder();
Random rd = new Random();
char ch;
for (int i = 0; i < size; i++)
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * rd.NextDouble() + 65)));
builder.Append(ch);
}
if (lowerCase)
return builder.ToString().ToLower();
return builder.ToString();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
StringBuilder builder = new StringBuilder();
builder.Append(RandomNumber(10, 99));
builder.Append(RandomString(3, true));
builder.Append(RandomString(2, false));
txtrobocomp.Text = builder.ToString();
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
SpVoice sp = new SpVoice();
sp.Volume = 90;
sp.Speak(txtrobocomp.Text);
//sp.WaitUntilDone(Timeout.Infinite);
}
I hope it will help you
Thanks& Regards
Aswini Aluri
Hanook159 reputationPosted Nov 14, 2013, 1:39 AM EST
http://dotnetlearners.com/blogs/view/6/Create-your-own-captcha-image-generator-in-aspnet-using-c-net.aspx
http://www.aspdotnet-suresh.com/2013/09/create-captcha-with-refresh-button-in-aspnet.html
http://www.ultimateprogrammingtutorials.info/2012/12/how-to-make-simple-captcha-control-in.html
Santosh GadgeRank #1,669 · 917 reputationPosted Jul 17, 2014, 9:57 PM EDT
http://www.c-sharpcorner.com/UploadFile/ca9151/generation-of-captcha-image-using-generic-handler/