Click here to Skip to main content
15,891,846 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

iam using captcha in asp.net with c# its working fine,but the problem is what ever captcha value i entered in text box that value i have to store in database, there are 5 characters in image as iam trying to store in database it is storing only one character
iam using this below code ,can anyone help me to get all characters

C#
<pre><%@ Register Assembly="MSCaptcha" Namespace="MSCaptcha" TagPrefix="cc1" %>


<table border="0" cellpadding="3" cellspacing="0">
<tr>
    <td colspan="3">
        Enter Text
        <asp:TextBox ID="txtCaptcha" runat="server"></asp:TextBox>
    </td>
</tr>
<tr>
    <td colspan="2">
        <cc1:CaptchaControl ID="Captcha1" runat="server" CaptchaBackgroundNoise="Low" CaptchaLength="5"
            CaptchaHeight="60" CaptchaWidth="200" CaptchaMinTimeout="5" CaptchaMaxTimeout="240"
            FontColor="#D20B0C" NoiseColor="#B1B1B1" />
    </td>
    <td>
        <asp:ImageButton ImageUrl="~/refresh.png" runat="server" CausesValidation="false" />
    </td>
</tr>
<tr>
    <td>
        <asp:CustomValidator ErrorMessage="Invalid. Please try again." OnServerValidate="ValidateCaptcha"
            runat="server" />
    </td>
    <td align="right">
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
    </td>
    <td>
    </td>
</tr>
</table>

protected void ValidateCaptcha(object sender, ServerValidateEventArgs e)
{
    Captcha1.ValidateCaptcha(txtCaptcha.Text.Trim());
    e.IsValid = Captcha1.UserValidated;
    if (e.IsValid)
    {
        ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Valid Captcha!');", true);
    }
}



can any body help me for getting

What I have tried:

i tried google serch as well,many examples but i can store only one character
Posted
Updated 24-Jan-17 17:23pm

1 solution

I suggest you to get the text box value in submit button click event and store in the database.
 
Share this answer
 
Comments
developerit 25-Jan-17 1:28am    
this submit button is for add to data base only..but the result is same
You are not getting the whole text from text box in button submit event?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900