【问题标题】:Bootstrap modal - how to display error message on submitBootstrap modal - 如何在提交时显示错误消息
【发布时间】:2017-04-24 20:58:01
【问题描述】:

我在我的应用程序中使用了一个引导模式,当我单击提交按钮时,模式关闭,因此无法显示错误消息。

有没有办法防止页面在提交时重新加载?

提交按钮:

<asp:Button runat="server" OnClick="PasswordChange" id="passwordChange" Text="Save" CssClass="btn btn-default"></asp:Button>

错误信息:

<asp:Label runat="server" ID="error1"></asp:Label>

C#:

protected void PasswordChange(object sender, EventArgs e)
{
    string currentPassword = cPassword.Text.ToString();
    string newPassword = nPassword.Text.ToString();
    string rePassword = rPassword.Text.ToString();

    db_connection();

    if (newPassword == rePassword)
    {
        Debug.WriteLine("Success" + newPassword + rePassword);
    }

    else
    {
        error1.Text = "Your passwords did not match, please try again";
    }
}

【问题讨论】:

    标签: c# html asp.net twitter-bootstrap


    【解决方案1】:

    可以使用 ajax 来防止刷新,例如

    $("#passwordChange").click(function (event) {
        var n = $('#nPassword').val();
        var r = $('#rPassword').val();
        if (n != r || n == "") {
            $('.passwordError').show();
            event.preventDefault();          
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-26
      • 2021-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多