【问题标题】:how to open modal popup on button click from server side如何从服务器端单击按钮打开模式弹出窗口
【发布时间】:2015-12-30 08:26:16
【问题描述】:
<%@ 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);
    }

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

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 是的。现在我从 3.aspx 页面中删除了 jquery 库,现在它可以正常工作了。非常感谢
    猜你喜欢
    • 1970-01-01
    • 2018-12-18
    • 2017-10-13
    • 1970-01-01
    • 1970-01-01
    • 2021-03-21
    • 2021-03-06
    • 1970-01-01
    • 2013-10-19
    相关资源
    最近更新 更多