Click here to Skip to main content
15,894,343 members
Home / Discussions / C#
   

C#

 
QuestionCalling an Extension method from another Extension method (C# 3.0) Pin
Rajesh Moriyani9-Jun-08 12:43
Rajesh Moriyani9-Jun-08 12:43 
AnswerRe: Calling an Extension method from another Extension method (C# 3.0) Pin
jamie5509-Jun-08 13:08
jamie5509-Jun-08 13:08 
AnswerRe: Calling an Extension method from another Extension method (C# 3.0) Pin
Tariq A Karim9-Jun-08 16:39
Tariq A Karim9-Jun-08 16:39 
Questionacessing an id from object sender Pin
brsecu9-Jun-08 10:55
brsecu9-Jun-08 10:55 
AnswerRe: acessing an id from object sender Pin
Edmundisme9-Jun-08 11:07
Edmundisme9-Jun-08 11:07 
GeneralRe: acessing an id from object sender Pin
brsecu10-Jun-08 2:05
brsecu10-Jun-08 2:05 
QuestionDatatable query Pin
NewToAspDotNet9-Jun-08 9:24
NewToAspDotNet9-Jun-08 9:24 
QuestionCAPTCHA Custom Server Control Pin
rgfirefly249-Jun-08 9:24
rgfirefly249-Jun-08 9:24 
OK guys its clunky but it works lol. Still have a little issue though maybe you guys can help me with a solution or just tell me it cant be done either way.

anyway, I can display the image and if the user types in the captcha it will validate, however since i had to do a if (!Page.IsPostBack) in order for the captcha text not to override itself upon every Async post back it now wont refresh the image if someone clicks get new image.

is there a way i can make this Unaffected by anything causing a post back except my label button?

The Control shown below is being placed onto my Default.aspx page. and the lblbutton is named lbtnCaptchaRefresh.

if i remember right i cant cross name spaces in a custom control since the name space of the current project will never be the same between two projects.

I've also thought about using it as an embedded resources, but not sure how that would work on dynamically created images.

here is the code:



  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Text;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Drawing;
  9. using System.Drawing.Drawing2D;
 10. using System.Drawing.Imaging;
 11. using System.IO;
 12. using System.Net;
 13.
 14. namespace Captcha
 15. {
 16.     [DefaultProperty("Text")]
 17.     [ToolboxData("<{0}:Captcha runat=server>")]
 18.     public class Captcha : WebControl //IHttpHandler
 19.     {
 20.
 21.         [Bindable(true)]
 22.         [Category("Appearance")]
 23.         [DefaultValue("")]
 24.         [Localizable(true)]
 25.
 26.
219.         public string BuildImage()
220.         {
270.
313.             captchafont.Dispose();
314.             captchafont2.Dispose();
315.             captchagraphic.Dispose();
316.             try
317.             {
318.                 captchabmp.Save(imageurl, ImageFormat.Jpeg);
319.             }
320.             catch (Exception ex)
321.             {
322.                 Context.Response.Write(ex.ToString());
323.             }
324.             HttpContext.Current.Session.Add("CaptchaURL", IMAGE);
325.             HttpContext.Current.Session.Add("captchastr", captchastr);
326.
327.             //HttpContext.Current.Session.Add("captchastr", captchastr);
328.             /*MemoryStream ms = new MemoryStream();
329.             Context.Response.Clear();
330.             Context.Response.ContentType = "image/jpeg";
331.             captchabmp.Save(ms, ImageFormat.Jpeg);
332.             ms.WriteTo(Context.Response.OutputStream);*/
333.
334.             captchabmp.Dispose();
335.
336.
337.             return imageurl;
338.         }
339.         protected override void OnInit(EventArgs e)
340.         {
341.             base.OnInit(e);
342.             if (!Page.IsPostBack)
343.             {
344.                 BuildImage();
345.             }
346.
347.         }
348.
349.         protected override void Render(HtmlTextWriter writer)
350.         {
351.
352.
353.             writer.RenderBeginTag("img src=\"" + imageurl + "\"");
354.             writer.RenderEndTag();
355.
356.             base.Render(writer);
357.
358.         }
359.
360.
361.     }
362. }

AnswerRe: CAPTCHA Custom Server Control Pin
Christian Graus9-Jun-08 13:23
protectorChristian Graus9-Jun-08 13:23 
GeneralRe: CAPTCHA Custom Server Control Pin
rgfirefly2410-Jun-08 5:06
rgfirefly2410-Jun-08 5:06 
QuestionHow to Select All CheckBoxes while GridView paging is allowed? Pin
nature02769-Jun-08 8:12
nature02769-Jun-08 8:12 
AnswerRe: How to Select All CheckBoxes while GridView paging is allowed? Pin
Member 84594004-Dec-11 19:47
Member 84594004-Dec-11 19:47 
QuestionHashtable containing DataTables [modified] Pin
steven33119-Jun-08 8:08
steven33119-Jun-08 8:08 
QuestionHow to create an undo function in a picturebox?(Console Application,using windows form) [modified] Pin
MrAdar9-Jun-08 7:46
MrAdar9-Jun-08 7:46 
AnswerRe: How to create an undo function in a picturebox?(Console Application,using windows form) Pin
Pete O'Hanlon9-Jun-08 9:16
mvePete O'Hanlon9-Jun-08 9:16 
AnswerRe: How to create an undo function in a picturebox?(Console Application,using windows form) Pin
Edmundisme9-Jun-08 11:09
Edmundisme9-Jun-08 11:09 
AnswerRe: How to create an undo function in a picturebox?(Console Application,using windows form) Pin
Christian Graus9-Jun-08 13:22
protectorChristian Graus9-Jun-08 13:22 
QuestionC# TreeView Control: How to color the nodes from the parent node to the last selected child node Pin
nikhilkardale9-Jun-08 7:35
nikhilkardale9-Jun-08 7:35 
QuestionHow to get all the shares from a machine Pin
matt23lucier9-Jun-08 6:57
matt23lucier9-Jun-08 6:57 
AnswerRe: How to get all the shares from a machine Pin
Ravi Bhavnani9-Jun-08 7:09
professionalRavi Bhavnani9-Jun-08 7:09 
GeneralRe: How to get all the shares from a machine Pin
matt23lucier9-Jun-08 7:17
matt23lucier9-Jun-08 7:17 
GeneralRe: How to get all the shares from a machine Pin
matt23lucier9-Jun-08 7:58
matt23lucier9-Jun-08 7:58 
Questionmaking a white black smooth animation Pin
Sajjad Izadi9-Jun-08 6:39
Sajjad Izadi9-Jun-08 6:39 
AnswerRe: making a white black smooth animation Pin
Christian Graus9-Jun-08 6:40
protectorChristian Graus9-Jun-08 6:40 
GeneralRe: making a white black smooth animation Pin
Sajjad Izadi9-Jun-08 6:49
Sajjad Izadi9-Jun-08 6:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.