Bootstrap Modal不能与asp.net一起使用

时间:2018-05-03 11:44:05

标签: c# asp.net bootstrap-modal

此模式根本没有弹出。模式应该在失败的登录尝试时弹出。 我已将设计和代码上传到代码后面以供参考。

这是设计页面代码。

<head runat="server">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
    <title>SFPL's AMS</title>
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
    <link rel="stylesheet" href="/assets/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/assets/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/assets/css/form-elements.css">
    <link rel="stylesheet" href="/assets/css/style.css">
    <link rel="shortcut icon" href="/assets/ico/favicon.png">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/assets/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/assets/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/assets/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="/assets/ico/apple-touch-icon-57-precomposed.png">
    <script src="/assets/js/jquery-1.11.1.min.js"></script>
    <script src="/assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="/assets/js/jquery.backstretch.min.js"></script>
    <script src="/assets/js/scripts.js"></script>
     <script type="text/javascript">
    function ShowPopup() {
        $("#btnShowPopup").click();
    }
</script>
</head>
<body >
    <div class="top-content">
        <div class="inner-bg">
            <div class="container">
                <div class="row">
                    <div class="col-sm-8 col-sm-offset-2 text">
                        <h1><strong>पदोन्नति</strong></h1>
                        <div class="description">
                             <p>
                                 Login Form Pre-Design Phase Starts Here.
                            </p>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6 col-sm-offset-3 form-box">
                        <div class="form-top">
                            <div class="form-top-left">
                                <h3>xxxxxxx</h3>
                                <p>Enter your username and password to log on:</p>
                            </div>
                            <div class="form-top-right">
                                <i class="fa fa-lock"></i>
                            </div>
                        </div>
                        <div class="form-bottom">
                            <form role="form" action="" method="post" class="login-form" runat="server">

                                <div class="form-group">
                                     <div class="input-group">
                                        <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                                        <asp:TextBox ID="txtUserName" CssClass="form-control"  placeholder="Enter User ID" runat="server"></asp:TextBox>  
                                    </div>
                                    <div class="input-group"> 
                                         <asp:RequiredFieldValidator runat="server" ControlToValidate="txtUserName"
                                        CssClass="text-danger" ErrorMessage="The user name field is required." />
                                    </div>
                                </div>
                                <div class="form-group">
                                     <div class="input-group">
                                        <span class="input-group-addon"><span class="fa fa-key"></span></span>
                                        <asp:TextBox ID="txtPassword" CssClass="form-control" placeholder="Enter Your Password" runat="server" TextMode="Password"></asp:TextBox>
                                    </div>
                                    <div class="input-group">
                                        <asp:RequiredFieldValidator runat="server" ControlToValidate="txtPassword" CssClass="text-danger" ErrorMessage="The password field is required." />
                                    </div>
                                </div>
                                <div class="form-group">
                                   <asp:Button ID="btnLogin" CssClass="btn btn-success" Text="Login" 
                                       runat="server" OnClick="btnLogin_Click" Style="width: 100%"> </asp:Button>
                                   <asp:Label ID="lblLoginSuccess" data-toggle="modal" data-target="#myModal" runat="server" ></asp:Label>  

                                </div>                         
                            </form>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <button type="button" style="display: none;" id="btnShowPopup" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
                        Launch demo modal
                    </button>          
                    <div class="modal fade" id="myModal">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title">
                                        Registration done Successfully</h4>
                                </div>
                                <div class="modal-body">
                                    <asp:Label ID="lblMessage" runat="server" />
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">
                                        Close</button>
                                    <button type="button" class="btn btn-primary">
                                        Save changes</button>
                                </div>
                            </div>
                            <!-- /.modal-content -->
                        </div>
                        <!-- /.modal-dialog -->
                    </div>
                    <!-- /.modal -->
                </div>
            </div>
        </div>
</body>

我从中复制了这段代码 幅(https://www.aspforums.net/Threads/111893/Open-Show-BootStrap-Modal-Popup-from-Server-Side-using-C-and-VBNet-in-ASPNet/

,这在新的网络应用程序中运行得非常好,但它根本不在这里工作。 请让我知道我错过了什么  从后面跑的是:

 protected void btnLogin_Click(object sender, EventArgs e)
{
     Cls_BA_FieldStaffEO user = new Cls_BA_FieldStaffEO();
     user.LoadFieldStaffbyUserAccountName(txtUserName.Text);
     lblLoginSuccess.CssClass = "error";
     lblLoginSuccess.Text = "";
     string password;

     if (txtPassword.Text != "" && user.Password != null)
     {
            password = Cls_StringHelpers.Decrypt(user.Password.Trim());
            //BEGIN: Fix for Bug ID -18020
            if (txtPassword.Text == password && user.IsActive == true)
            {
                //END: Fix for Bug ID - 18020
                Session["Roles"] = (Cls_MA_RoleEOList)ViewState["Roles"];
                Session["UserID"] = user.ID;
                Session["UserName"] = user.UserAccountName;
                Session["BaseRegionID"] = user.RegionID;
                Session["BaseRegionName"] = user.RegionName;
                Session["BaseDistrictID"] = user.DistrictID;
                Session["BaseDistrictName"] = user.DistrictName;
                Session["BaseBranchID"] = user.BranchID;
                Session["BaseBranchName"] = user.BranchName;
                Session["BaseUnitID"] = user.UnitID;
                Session["BaseUnitName"] = user.UnitName;
            //Session["Ver"] = trigger.InnerText.Trim();
            //Session["VerToolTip"] =Convert.ToString(ViewState["VerToolTip"]); 
                if (user.CheckDuplicateLogUser(Convert.ToInt32(Session["UserID"])))
                {

                //lblMsg.CssClass = "error";
                Cls_MA_ListLoginUserResultBOList LoginDetails = new Cls_MA_ListLoginUserResultBOList();
                LoginDetails.List(Convert.ToInt32(Session["UserID"]));
                Session["UnitID"] = LoginDetails[0].UnitId;
                //lblLoginSuccess.CssClass = "text-danger";
                //lblLoginSuccess.Text = "<b>Please Logout As You Are ALREADY LOGGED IN </b> From <b>" + LoginDetails[0].UnitName.Trim() + "</b> Unit.<br/>Or<br />The <b>Browser Was Closed</b> Forcefully.";
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowPopup();", true);
                this.lblMessage.Text = "Your Registration is done successfully. Our team will contact you shotly";
            }
                else
                {

                    Response.Redirect("~/Common/f_CN_OuterHome.aspx");
                }

            }
            else
            {
            //lblLoginSuccess.Text = (string)HttpContext.GetGlobalResourceObject("Master_ErrorMessages", "regLoginSuccess");
            //lblLoginSuccess.CssClass = "text-danger";
            //ClearControls();
            ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowPopup();", true);
            this.lblMessage.Text = "Your Registration is done successfully. Our team will contact you shotly";
        }
        }
        else
        {
        //lblLoginSuccess.Text = (string)HttpContext.GetGlobalResourceObject("Master_ErrorMessages", "regLoginSuccess");
        //lblLoginSuccess.CssClass = "text-danger";
        //ClearControls();
        ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowPopup();", true);
        this.lblMessage.Text = "Your Registration is done successfully. Our team will contact you shotly";
    }

}

0 个答案:

没有答案