This is a migrated thread and some comments may be shown as answers.

More captcha's on the same page

6 Answers 124 Views
Captcha
This is a migrated thread and some comments may be shown as answers.
Hessner
Top achievements
Rank 2
Hessner asked on 13 Dec 2009, 08:41 PM
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!

6 Answers, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 16 Dec 2009, 01:57 PM
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.
0
Pero
Telerik team
answered on 17 Dec 2009, 03:13 PM
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.
0
Hessner
Top achievements
Rank 2
answered on 19 Dec 2009, 08:10 PM
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.
0
Pero
Telerik team
answered on 21 Dec 2009, 02:00 PM
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.
0
Hessner
Top achievements
Rank 2
answered on 21 Dec 2009, 05:34 PM

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.

0
Pero
Telerik team
answered on 22 Dec 2009, 01:54 PM
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.
Tags
Captcha
Asked by
Hessner
Top achievements
Rank 2
Answers by
Pero
Telerik team
Hessner
Top achievements
Rank 2
Share this question
or