Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将刷新按钮添加到mscaptcha组件?_C#_Asp.net_Captcha - Fatal编程技术网

C# 如何将刷新按钮添加到mscaptcha组件?

C# 如何将刷新按钮添加到mscaptcha组件?,c#,asp.net,captcha,C#,Asp.net,Captcha,如何将刷新按钮添加到mscaptcha组件中,以便在不按用户刷新页面的情况下更改代码 我正在使用: <httpHandlers> <add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/> </httpHandlers> 在Visual C#中,您编写的代码位于webconfig上。在您的页面上编写以下代码: //ScriptMan

如何将刷新按钮添加到mscaptcha组件中,以便在不按用户刷新页面的情况下更改代码

我正在使用:

<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>


在Visual C#

中,您编写的代码位于webconfig上。在您的页面上编写以下代码:

  //ScriptManager is necessary for update panel
    <asp:ScriptManager ID="sm" runat="server">
    </asp:ScriptManager>
    <div>
        Please enter text
        <asp:TextBox ID="txtCaptcha" runat="server"></asp:TextBox>
    </div>
    // you should use update panel because you want just the captch refresh not all
    the page.
    <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>
            <div>
                <div style="display: inline-block">
                    //its captcha control
                    <cc1:CaptchaControl ID="Captcha1" runat="server" CaptchaBackgroundNoise="Low" CaptchaLength="5"
                        CaptchaHeight="60" CaptchaWidth="200" CaptchaMinTimeout="5" CaptchaMaxTimeout="240"
                        FontColor="#D20B0C" NoiseColor="#B1B1B1" />
                </div>
                <div style="display: inline-block">
                    // its your refresh button
                    <asp:ImageButton ImageUrl="~/refreshpic.png" runat="server" CausesValidation="false" />
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <div>
        <div>
            <asp:CustomValidator ErrorMessage="Invalid." OnServerValidate="ValidateCaptcha" runat="server" />
        </div>
        <div>
            <asp:Button ID="btnSubmit" runat="server" Text="Register" />
        </div>
    </div>
 protected void ValidateCaptcha(object sender, ServerValidateEventArgs e)
    {
        Captcha1.ValidateCaptcha(txtCaptcha.Text.Trim());
        e.IsValid = Captcha1.UserValidated;
        if (e.IsValid)
        {
          //do some thing
        }
    }