More captcha's on the same page

7 posts, 1 answers
  1. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 13 Dec 2009 Link to this post

    Hi,

    if a page consist of more then one ascx file containing the code below,
    then the correct captcha code can never be entered by the user(isValid allways = false).

    <table style="border: solid 1px #323232; background-color: #efefef">  
      <tr valign="bottom">  
        <td colspan="2">  
          <span style="font-weight: bold; font-size: 11px">For en sikkerheds skyld...</span> 
        </td> 
      </tr> 
      <tr valign="bottom">  
        <td style="background-color: #efefef">  
          <telerik:RadCaptcha ID="RadCaptcha1" runat="server" CaptchaImage-RenderImageOnly="true" CaptchaImage-Height="32" 
           CaptchaImage-Width="90" CaptchaImage-TextColor="#323232" CaptchaImage-LineNoise="Low" CaptchaImage-FontWarp="None"
           CaptchaImage-BackgroundColor="#efefef" ErrorMessage="Tast koden igen!" Display="Dynamic" 
           CaptchaTextBoxCssClass="captchaBox"  ImageStorageLocation="Cache" EnableViewState="true">  
          </telerik:RadCaptcha> 
          <div style="padding-bottom: 7px"></div> 
        </td> 
        <td> 
          <asp:TextBox ID="CaptchaInput" runat="server" MaxLength="5" Width="50" Font-Size="13px" BackColor="white">
          </asp:TextBox> 
          <br /> 
          <span style="background-color: #efefef; color: #000">Tast koden</span> 
        </td> 
      </tr> 
    </table> 

    <asp:Button ID="Tilmeld" OnClick="SendEmailNu" title="Tilmeld" runat="server" CssClass="button" Text="Tilmeld">
    </asp:Button> 

    Code behind like this:
    protected void SendEmailNu(Object sender, EventArgs e)  
      {  
      RadCaptcha1.ValidatedTextBoxID = CaptchaInput.UniqueID;  
      RadCaptcha1.Validate();  
      if (RadCaptcha1.IsValid)  
        {  
     

    If only one r.a.d.captcha, with this "external" textbox approace is on the page - then no problem!

  2. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 16 Dec 2009 Link to this post

    Hi Hessner,

    I did reproduce the problem locally. After researching the problem it seems that the issue is related to the RadCaptcha control. I logged the issue for fixing and will follow up in this thread to update you on the progress made. 

    I have updated your account with 300 Telerik points for reporting the problem.

    Regards,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 17 Dec 2009 Link to this post

    Hi Hessner,

    The problem has been fixed. The fix will be available through the internal builds (probably in the beginning of next week). Please test the fix and let us know in case you experience any unexpected behavior.

    Best wishes,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 19 Dec 2009 Link to this post

    Hi,

    I have downloaded an installed version: 2009.3.1219.35

    I regret to inform you that now my example will NEVER validate,- not even with only one captcha on the page.

    Please note that I am using an external TextBox.
  6. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 21 Dec 2009 Link to this post

    Hello Hessner,

    I forgot to mention in my previous post that we also made changes to the way the Captcha control searches for the custom validated textbox. In the latest official release RadCaptcha looks for the textbox in the NamingContainer of the Page, and in the latest internal build in the NamingContainer where the Captcha control belongs (i.e. in the same NamingContainer where the Captcha control is placed). So it is enough to supply the ID of the validated textbox to the RadCaptcha's ValidatedTextBoxID property and the input will be validated correctly.

    Let us know if the issue persists even after you modify the Captcha controls to use the IDs instead of the UniqueIDs.

    For more info: http://www.telerik.com/community/forums/aspnet-ajax/captcha/captcha-control-in-a-login-control.aspx

    Best wishes,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 21 Dec 2009 Link to this post

    Hi,

    1. If the ID are set in code behind - then the test will fail the first time, secund time it will not fail.

    2. If the ID are set in ascx - then the test will succeed first time(OK)

    3. If the ID are set in ascx - and there are two capthas's on the same page, then the first captcha entered will succeed(OK) - the secund captcha entered will behave like 1.(WRONG)

    Both Captha's are placed inside their separate update panel - on the same page.

    Update: partial updates explain behaviour in 3., and are solved with this code inside the Page_Load event: 

     

    if

     

    (System.Web.UI.ScriptManager.GetCurrent(this.Page).IsInAsyncPostBack)

     

    {

    UpdatePanel1.Update();

    }
    Now the correct picture are displayed.

  8. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 22 Dec 2009 Link to this post

    Hi Hessner,

    1. It depends at what stage in the ASP.NET page life-cycle the TextBoxID is set to the RadCaptcha ValidatedTextBoxID property. For example, if it is set in the button's click event and at the same time this button serves as the one which will validate the code (i.e. CausesValidation="true" and the ValidationGroup is the same as the one set to the Captcha control) the input will not be validated correctly, because the RadCaptcha gets the text from the custom textbox in the LoadPostData method which is fired before the Load and after the Init event. This means that the RadCaptcha tried to get the input from the custom textbox before the ID was actually assigned to the RadCaptcha.ValidatedTextBoxID property.

    Please set the ValidatedTextBoxID property before the LoadPostData is executed (i.e. Page_Init), or set it when the page validation does not occur, and let me know if the code is validated correctly.

    3. When an AJAX request is fired, the server-side page goes through its full page lifecycle. This means that a new RadCaptcha code will be generated, but because it's an AJAX update it would not be shown on the image (the old code is still shown because the RadCaptcha is not affected by the partial page update). So, the user sees the old code and enters it correctly but still gets an Error Message, because this old code is not valid anymore. To overcome this issue, the Captcha control should be placed inside the UpdatePanel.


    Kind regards,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017