5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 18 Jul 2013, 06:04 AM
Hi
Please have a look into the following sample code i tried which works fine as expected.
ASPX:
JavaScript:
C#:
Thanks,
Shinu.
Please have a look into the following sample code i tried which works fine as expected.
ASPX:
<telerik:RadTextBox ID="RadTextBox1" runat="server" Label="UserName : "></telerik:RadTextBox><telerik:RadTextBox ID="RadTextBox2" runat="server" Label="Password : " TextMode="Password"></telerik:RadTextBox><telerik:RadCaptcha ID="RadCaptcha1" runat="server" ProtectionMode="InvisibleTextBox"></telerik:RadCaptcha><asp:Label ID="Label1" runat="server"></asp:Label><telerik:RadButton ID="btnVerify" runat="server" Text="Submit" OnClick="btnVerify_Click"></telerik:RadButton><br /><br /><asp:CheckBox ID="CheckBox1" runat="server" Text="Fill the Invisible TextBox to invalidate page" onclick="fillInvisibleTextBox(this);" />JavaScript:
<script type="text/javascript"> function fillInvisibleTextBox(sender) { var invisibleTextBox = $get("<%=RadCaptcha1.ClientID %>_InvisibleTextBox"); if (sender.checked) { invisibleTextBox.value = "SomeText"; } else { invisibleTextBox.value = ""; } }</script>C#:
protected void btnVerify_Click(object sender, EventArgs e){ if (Page.IsValid) { Label1.ForeColor = System.Drawing.Color.Green; Label1.Text = "Page submitted successfully!<br/><br/>"; } else { Label1.ForeColor = System.Drawing.Color.Red; Label1.Text = "Page not submittes. Invisible textbox was filled by a bot!<br/><br/>"; }}Thanks,
Shinu.
0
Saravanan
Top achievements
Rank 1
answered on 20 Sep 2013, 04:55 AM
Hi shinu
Is it possible to get the captcha text in code behind? I tried but I am getting some invalid characters not same as the one in the captcha text.
Is it possible to get the captcha text in code behind? I tried but I am getting some invalid characters not same as the one in the captcha text.
0
Shinu
Top achievements
Rank 2
answered on 20 Sep 2013, 05:25 AM
Hi Saravanan,
It is possible to get the RadCaptcha text in code behind. Suppose you are trying to access the RadCaptcha text in code behind you wont get the exact text displayed in the RadCaptcha image. This is because when the control post back, the RadCaptcha is updated with a new captcha image and the characters that are displayed in the updated image will be received in your C# code and hence you get some new characters which you described as invalid. You can try the following code to access the captcha text.
C#:
Hope this helps,
Shinu.
It is possible to get the RadCaptcha text in code behind. Suppose you are trying to access the RadCaptcha text in code behind you wont get the exact text displayed in the RadCaptcha image. This is because when the control post back, the RadCaptcha is updated with a new captcha image and the characters that are displayed in the updated image will be received in your C# code and hence you get some new characters which you described as invalid. You can try the following code to access the captcha text.
C#:
protected void Page_Init(object sender, EventArgs e){ if (!IsPostBack) { Session["CaptchaCode"] = RadCaptcha1.CaptchaImage.Text; }}protected void RadButton1_Click(object sender, EventArgs e){ Response.Write("<script>alert('" + Session["CaptchaCode"].ToString() + "')</script>"); //your code Session["CaptchaCode"] = RadCaptcha1.CaptchaImage.Text; //updating with new captcha text.}Hope this helps,
Shinu.
0
Saravanan
Top achievements
Rank 1
answered on 21 Sep 2013, 02:12 AM
Hi shinu
Instead of using a label, is it possible to add an icon to generate a new captcha image?
Instead of using a label, is it possible to add an icon to generate a new captcha image?
0
Shinu
Top achievements
Rank 2
answered on 21 Sep 2013, 04:06 AM
Hi Saravanan,
Please have a look at the following code I tried which works fine at my end.
ASPX:
CSS:
Thanks,
Shinu.
Please have a look at the following code I tried which works fine at my end.
ASPX:
<telerik:RadCaptcha ID="CaptchaCode" runat="server" EnableRefreshImage="true" CaptchaLinkButtonText="<br/>"></telerik:RadCaptcha>CSS:
<style type="text/css"> .rcRefreshImage { background-image: url('../Images/refresh.png'); background-repeat: no-repeat; margin-left: 185px; margin-top: -20px; }</style>Thanks,
Shinu.