1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Two Captchas on a same page

Two Captchas on a same page

10 posts, 2 answered
  1. Angel
    Angel avatar
    32 posts
    Registered:
    04 Feb 2008
    19 Apr 2010
    Link to this post
    Hi I'd like to have two captchas on one page. So far I was doing this:

    - In Captcha.aspx's pageload event I put this:

    protected void Page_Load(object sender, EventArgs e)
    {
        CaptchaImage ci = new CaptchaImage();
        ci.TextLength = CaptchaLength;
        ci.Width = CaptchaWidth;
        ci.Height = CaptchaHeight;
        Bitmap bmp = ci.RenderImage();
        string text = ci.Text;
        Session.Add(Constants.SESSION_CAPTCHA_IMAGE, text);
     
        Response.ContentType = "image/jpeg";
        bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
     
        bmp.Dispose();
        Response.End();
    }

    And to use it in an other page I do:

    imgCap.ImageUrl = "../Captcha.aspx";

    But now I want to have two images (for two different things) no the same page and I get on both the same image. Any suggestions how can I do that with two different images?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Apr 2010
    Link to this post
    Hello Angel,

    You should have two different   RadCaptcha controls

    <telerik:RadCaptcha runat="server"  ID="RadCaptcha1"></telerik:RadCaptcha>
     
    <telerik:RadCaptcha runat="server"  ID="RadCaptcha2"></telerik:RadCaptcha>


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  3. Angel
    Angel avatar
    32 posts
    Registered:
    04 Feb 2008
    20 Apr 2010
    Link to this post
    Hi Ivan,

    Thanks!! That works just great!

    Just one thing, how can I put the captcha image and the textbox on the same line. Right now they are put in <p></p> and are not on the same line?
  4. Angel
    Angel avatar
    32 posts
    Registered:
    04 Feb 2008
    20 Apr 2010
    Link to this post
    And one more thing about the license - do we need some more license to use this RadCaptcha control, except Sitefinity's license?
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    20 Apr 2010
    Link to this post
    Hi Angel,

    1. You could add styles to the image and p tag of the RadCaptcha

    .RadCaptcha img
    {
        float:left !important;
    }
     
    .RadCaptch p
    {
       margin: 10px 0px 0px 200px !important;
       padding-top: 10px !important;
    }

    There are not any special css classes that the control uses, so you can use common css rules.

    2. Sitefinity license allows you to use the RadControls for the Telerik.Web.UI.dll that is shipped within the Sitefinity project.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
    Answered
  6. Angel
    Angel avatar
    32 posts
    Registered:
    04 Feb 2008
    23 Apr 2010
    Link to this post
    Hi,

    How can I get the value of the textbox of the radcaptcha control from the code behind?
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    23 Apr 2010
    Link to this post
    Hi Angel,

    You could do it from the code behind of your control

    var captchaTextBox = RadCaptcha1.FindControl("CaptchaTextBox");

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Angel
    Angel avatar
    32 posts
    Registered:
    04 Feb 2008
    23 Apr 2010
    Link to this post
    Hi Ivan,

    That is what I tried to do, but it didn't work. It actually finds the text box, but the Text property hold empty string. The thing that might make it not working is that I use it in UpdatePanel. Do you think that can cause the problem?

    Kind Regards,
    Angel
  9. Angel
    Angel avatar
    32 posts
    Registered:
    04 Feb 2008
    23 Apr 2010
    Link to this post
    Hi,

    The problem is that on each reload the captcha has new value and it doesn't remember its old one! How can I overcome this?
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    25 Apr 2010
    Link to this post
    Hi Angel,

    You could store the old value in cookie, session, query string.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
10 posts, 2 answered