ASP.NET 3.5 and above only

Obout.Ajax.UI Controls - Captcha - In UserControl with audio feature

 
Registration Form

*
*



The sourse code of this example you can find in the downloaded Suite. See the file Captcha/cs_UserControlWithAudio.aspx or Captcha/vb_UserControlWithAudio.aspx.
UserControl: Captcha/UserControls/MyCaptchaWithAudio.ascx.
ASP.NET
<%@ Register Assembly="Obout.Ajax.UI" Namespace="Obout.Ajax.UI.Captcha" TagPrefix="obout" %>
<%@ Register Src="UserControls/MyCaptchaWithAudio.ascx" TagName="Captcha" TagPrefix="site" %>

<b>Registration Form</b><br /><br />
<obout:OboutTextBox runat="server" ID="FirstName" WatermarkText="First name" Width="229"
    FolderStyle="~/interface/styles/black_glass/OboutTextBox" /> *
<asp:RequiredFieldValidator ID="FirstValidator" runat="server" ControlToValidate="FirstName"
    EnableClientScript="true" ValidationGroup="SubmitInfo" InitialValue="First name"
    ErrorMessage="Please fill in first name!" Display="Dynamic" /><br />
<obout:OboutTextBox runat="server" ID="LastName" WatermarkText="Last name" Width="229" /> *
<asp:RequiredFieldValidator ID="LastValidator" runat="server" ControlToValidate="LastName"
    EnableClientScript="true" ValidationGroup="SubmitInfo" InitialValue="Last name"
    ErrorMessage="Please fill in last name!" Display="Dynamic" />
<site:Captcha runat="server" ID="Captcha1" ValidationGroup="SubmitInfo" />

<asp:Button runat="server" Text="Submit the form" ValidationGroup="SubmitInfo" />
MyCaptchaWithAudio.ascx
<%@ Language="C#" ClassName="MyCaptchaWithAudio" AutoEventWireup="true" %>
<%@ Register Assembly="Obout.Ajax.UI" Namespace="Obout.Ajax.UI.Captcha" TagPrefix="obout" %>
<%@ Register TagPrefix="obout" Namespace="Obout.Interface" Assembly="obout_Interface" %>

<script runat="server" language="c#">
    /// <summary>
    /// Some things before the control render 
    /// </summary>
    protected void Page_PreRender(object sender, EventArgs e)
    {
        // clear the input field
        CaptchaInputField.Text = "";
        // set 'onclick' of the "Generate a new image" button
        GenerateNew.Attributes<"onclick"] = "$find('" + InnerCaptchaImage.ClientID + "').getNewImage();";
    }
    /// <summary>
    /// Validation group
    /// </summary>
    public string ValidationGroup
    {
        get { return CaptchaValidator.ValidationGroup; }
        set { CaptchaValidator.ValidationGroup = value; }
    }
</script>
<style type="text/css">
    #<%= MainTable.ClientID %> {
        border:1px solid gray;
        background-color: WhiteSmoke;
        border-radius: 5px;  
        -moz-border-radius: 5px;  
        -webkit-border-radius: 5px;
    }
</style>
<table runat="server" id="MainTable">
    <tr>
        <td valign="middle">
            <obout:CaptchaImage ID="InnerCaptchaImage" runat="server" TextLength="5"
                BackColor="WhiteSmoke" TextBrush="Horizontal" BackBrush="Solid"
                BrushFillerColor="WhiteSmoke" BackgroundNoise="High" LineNoise="High"
                FontFamily="Georgia" FontWarpLevel="None"
                AudioEnabled="true" AudioLinkID="GetAudioCode" />
        </td>
        <td valign="middle">
                <asp:Image runat="server" alt="" title="Generate a new image" ID="GenerateNew"
                    ImageUrl="~/Captcha/UserControls/Refresh.gif" style="cursor: pointer" />
        </td>
    </tr>
    <tr>
        <td align="left">
            <obout:OboutTextBox runat="server" ID="CaptchaInputField"
                WatermarkText="Type the code from the image" Width="200"
                FolderStyle="~/interface/styles/black_glass/OboutTextBox" />
        </td>
        <td valign="middle">
            <asp:HyperLink runat="server" ID="GetAudioCode">
                <asp:Image runat="server" alt="" title="Get audio code"
                    ImageUrl="~/Captcha/UserControls/Audio.png" style="cursor: pointer" />
            </asp:HyperLink>
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center">
            <obout:CaptchaValidator runat="server" CaptchaImageID="InnerCaptchaImage"
                ErrorMessage="The code you entered is not valid." ID="CaptchaValidator"
                ControlToValidate="CaptchaInputField" Display="Dynamic" />
        </td>
    </tr>
</table>

"After evaluating around 10 html editors I found yours and made a quick decision that it is simply the best one I have found."

Shawn Richards
InterThingy Technologies

Random testimonial   All testimonials