twitter-bootstrap 如何在服务器端单击按钮时打开模态弹出窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34525669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 23:29:25  来源:igfitidea点击:

how to open modal popup on button click from server side

c#jqueryasp.nettwitter-bootstrap

提问by radha singh

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="3.aspx.cs" Inherits="KVTRANSAPORTS._3" MasterPageFile="~/Site1.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="Scripts/jquery-2.1.1.min.js"></script>
    <script src="Scripts/bootstrap.min.js"></script>
    <script type="text/javascript">
        function openModal() {
            $('#myModal').modal('show');
        };
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="container">
        <div class="btn-group">
            <asp:Button ID="btnSubmit" class="btn-info" runat="server" Text="Submit"
                OnClick="btnSubmit_Click"></asp:Button>
        </div>
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
            aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h4 class="modal-title" id="myModalLabel">title
                        </h4>
                    </div>
                    <div class="modal-body">
                        something
                    </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
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
    }

it is giving error Uncaught TypeError: $(...).modal is not a function

它给出了错误 Uncaught TypeError: $(...).modal is not a function

采纳答案by Edgaras

Have your checked ~/Site1.Master ? Maybe your MasterPage includes jQuery library too?

你检查过 ~/Site1.Master 吗?也许您的 MasterPage 也包含 jQuery 库?

TypeError: $(...).modal is not a function with bootstrap Modal

TypeError: $(...).modal 不是带有 bootstrap Modal 的函数