Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,


i want captcha code with refresh button...refresh button should work with update panel so that only the captcha image will change partially.....i searched in net but refresh button will work with full postback only.....actually here i want in partial postback.....


and no use of dll.......



please help me
Posted
Updated 8-Apr-13 20:06pm
v2
Comments
Sergey Alexandrovich Kryukov 9-Apr-13 2:11am    
Did you try to find anything?
—SA

This CodeProject article, for example: Simple CAPTCHA, Create your own in C#[^].

—SA
 
Share this answer
 
Comments
Member 9155255 9-Apr-13 2:23am    
The link what u send....that code i have already implemented....but i got stuck in refresh button....the requirement is along with captcha image i want one refresh button...when u click on refresh button the captcha image should change with partial postback(fullpostback should not happen)...this i should do without using dll.....
esmael taher 13-Oct-13 2:48am    
hi my friends.I have a same problem with reloading captcha image without reloadin other items. can any one explain me "How I Can Reload Only Captch aImage?"
Sergey Alexandrovich Kryukov 9-Apr-13 2:34am    
I have no information on where did you stuck and why...
—SA
Member 9155255 9-Apr-13 2:46am    
in ur example refreshing captcha image is not there,before submiting to the page.....that i want ....can u help me
Sergey Alexandrovich Kryukov 9-Apr-13 11:00am    
I did not pay attention for that, but... is it really difficult to add refreshing?
I guess, you would need drawing alternative captcha image over and over on the user request. But look, if it is already done once in the available code, why not adding a small modification of the code to do repeat it over and over? You should never expect that someone gives you exactly what you want (people don't develop software on your orders); you are supposed to contribute to implementation of your own goals...

So, how about the following: you try to create the modified code and ask another question if you face a brick wall?

—SA
In Page_Load


protected void Page_Load(object sender, EventArgs e)
{
Bitmap obj = new System.Drawing.Bitmap(150, 50);
Graphics objGraphics = System.Drawing.Graphics.FromImage(obj);
objGraphics.Clear(Color.LightGray);
objGraphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

Font objFont = new Font("Arial", 25, FontStyle.Italic | FontStyle.Strikeout);



Random r = new Random();
int startIndex = r.Next(1, 5);
int length = r.Next(4, 7);

String randomStr = Guid.NewGuid().ToString().Replace("-", "0").Substring(startIndex, length);

Session.Add("randomStr", randomStr);


objGraphics.DrawString(randomStr, objFont, Brushes.DodgerBlue, 5, 5);


Response.ContentType = "image/GIF";
obj.Save(Response.OutputStream, ImageFormat.Gif);

objFont.Dispose();
objGraphics.Dispose();
objBMP.Dispose();
}

And in other Page

TAke One Button, Image Control And one textbox
pu this below code under image control

img height="30" alt="Captcha" src="Test.aspx" style="width: 99px" />

put this below code under button click

protected void Button1_Click(object sender, EventArgs e)
{

if (TextBox1.Text.ToString() == Session["randomStr"].ToString())
{
Label1.Text = "Your Form is submitted";
}
else
{
Label1.Text = "Please enter input correctly";
}
txtTest.Text = string.Empty;
txtTest.Focus();

}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900