验证码重新加载和声音按钮

时间:2017-08-29 14:21:54

标签: asp.net captcha

我在asp.net网页上使用验证码时遇到问题。 除了重新加载和声音按钮不在应有的验证码图像旁边之外,一切似乎都能正常工作。相反,它们位于文本框下方(图像下方)

captcha_error

有关如何解决此问题的任何帮助?

代码是:

    <fieldset>
    <legend>Registration Form</legend>
    <ol>
        <li class="email">
            <label for="email" @if(!ModelState.IsValidField("email")){<text>class="error-label"</text>}>Email address</label>
            <input type="text" id="email" name="email" value="@email" @Validation.For("email") />
            @* Write any email validation errors to the page *@
            @Html.ValidationMessage("email")
        </li>
        <li class="password">
            <label for="password" @if(!ModelState.IsValidField("password")) {<text>class="error-label"</text>}>Password</label>
            <input type="password" id="password" name="password" @Validation.For("password") />
            @* Write any password validation errors to the page *@
            @Html.ValidationMessage("password")
        </li>
        <li class="confirm-password">
            <label for="confirmPassword" @if(!ModelState.IsValidField("confirmPassword")) {<text>class="error-label"</text>}>Confirm password</label>
            <input type="password" id="confirmPassword" name="confirmPassword" @Validation.For("confirmPassword") />
            @* Write any password validation errors to the page *@
            @Html.ValidationMessage("confirmPassword")
        </li>
        <li class="recaptcha">
                @Html.Label("Retype the code from the picture:", "CaptchaCode")
                <p></p>
                @{
                Captcha exampleCaptcha = new Captcha("ExampleCaptcha");
                exampleCaptcha.CodeLength = 4;
                exampleCaptcha.ImageSize = new System.Drawing.Size(240, 70);
                exampleCaptcha.UseHorizontalIcons = true; 
                exampleCaptcha.UserInputID = "CaptchaCode";
                exampleCaptcha.AdditionalCssClasses = "class1 class2 class3";
                }

                @Html.Raw(exampleCaptcha.Html)

                @Html.TextBox("CaptchaCode")


       </li>
    </ol>
    <input type="submit" value="Register" />
</fieldset>

谢谢, 迪尼斯

1 个答案:

答案 0 :(得分:0)

好的伙计们,问题解决了!

我忘记在头部添加以下行:

{% extends "admin/change_list.html" %}

{% block content_title %}
    <h1>Title</h1>
{% endblock %}

{% block result_list %}
    <div class="results">
        <table id="result_list">
            <thead>
                ...
            </thead>

            <tbody>
                {% for item in items %}
                    <tr class="{% cycle 'row1' 'row2' %}">
                        ...
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}