Boostrap Modal Popup在使用asp.net C#页面referesh后没有显示

时间:2017-02-27 10:32:47

标签: javascript c# jquery asp.net twitter-bootstrap

如果用户不存在,我想显示模态弹出窗口,但如果用户不存在,模态弹出窗口就会消失。

<a href="#" class="btn btn-primary btn-xl page-scroll" role="button" data-toggle="modal" data-target="#login-modal" runat="server" id="pnl_login"><i class="fa fa-key" aria-hidden="true" style="margin-right: 8px;"></i>Login</a>

    <div id="login-form">
                        <div class="modal-body">
                            <asp:TextBox ID="txt_UserName" runat="server" ValidationGroup="login" CssClass="form-control" autocomplete="off" placeholder="Enter Email ID"></asp:TextBox>
                            <div class="error-msg text-left">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please Specify Your Email Id" ControlToValidate="txt_UserName" ValidationGroup="gr_in" ForeColor="Red"></asp:RequiredFieldValidator></div>
                            <asp:TextBox ID="txt_Password" runat="server" CssClass="form-control" ValidationGroup="login" TextMode="Password" autocomplete="off" placeholder="Enter Password"></asp:TextBox>
                            <div class="error-msg text-center">
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter your Password" ControlToValidate="txt_UserName" ValidationGroup="gr_in" ForeColor="Red"></asp:RequiredFieldValidator>

                            </div>
                            <div class="error-msg text-center">
                                <asp:Label ID="lbl_errormsg" runat="server" Visible="false" ForeColor="red"></asp:Label>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <div>
                                <asp:Button ID="btn_Login" runat="server" Text="Login" OnClick="btn_Login_Click" CssClass="btn btn-primary btn-lg btn-block" ValidationGroup="gr_in" />
                            </div>
                            <div>
                                <asp:Button ID="btn_LostPassword" runat="server" Text="Forgot password?" OnClick="btn_LostPassword_Click" CssClass="btn btn-link" />
                                <asp:Button ID="btn_Register" runat="server" Text="New User?" OnClick="btn_Register_Click" CssClass="btn btn-link pull-right" />
                            </div>
                        </div>
                    </div>

下面是按钮点击代码,我想显示模态弹出窗口,如果状态不成功,我在其他情况下编写脚本代码但是pop pup正在显示,我知道如果用户不存在那么模态弹出不应该去。< / p>

protected void btn_Login_Click(object sender, EventArgs e)
{

    string StatusMsg = string.Empty;
    bo.Para1 = txt_UserName.Text;//UserName
    bo.Para2 = txt_Password.Text;//Password

    bo.Para3 = this.Page.Request.ServerVariables["REMOTE_ADDR"]; // SystemIp
    HttpBrowserCapabilities browserInfo = Request.Browser;
    bo.Para4 = browserInfo.Browser; //BrowserType
    bo.Para5 = browserInfo.Version;//Browser Version
    bo.Para6 = browserInfo.Platform;//OperatingSystem
    bl.Get_User_Login(bo, out LoginDetails, out StatusMsg);
    if (StatusMsg == "Success")
    {

        ShowResult();
    }
    else
    {

        lbl_errormsg.Visible = true;
        lbl_errormsg.Text = StatusMsg;

        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", "<script>$('#login-modal').modal('show');</script>", true);
    }
}

0 个答案:

没有答案