从绝对失败的代码打开模态 [英] Opening modal from code behind absolute failure

查看:92
本文介绍了从绝对失败的代码打开模态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过调用Javascript函数在后面的代码段结束时触发Bootstrap模式,它将运行函数中的alert(),但坚决拒绝显示我尝试的任何模态。 />


代码背后的部分: -



I am trying to fire a Bootstrap Modal at the end of a section of code behind by calling a Javascript function, it will run the alert() that is in the function but steadfastly refuses to display any modal I try.

Code behind partial :-

ScriptManager.RegisterStartupScript(Me, Page.GetType(), "Script", "openModal();", True)





内容页面上的Javascript函数: - < br $>




And the Javascript Function on the content page :-

<%@ Page Title="" Language="vb" AutoEventWireup="False" MasterPageFile="~/Site.Master" CodeBehind="clientprocess.aspx.vb" Inherits="UPARS.clientprocess" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

    <asp:ScriptManager ID="ScriptManager1" runat="server"
        EnablePageMethods="true">
    </asp:ScriptManager>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <style>
        .GridViewClass td, th {
            padding: 4px;
        }
    </style>


    <script type="text/javascript">

        function openModal() {
            alert("howdy");
           $('#chqPayModal').modal('show');
        }

    </script>





和模态代码: -





And the Modal code:-

<pre>   <div class="modal modal-dialog-centered fade " id="chqPayModal" tabindex="-1" role="dialog" aria-labelledby="chqPayModal" aria-hidden="true">
        <div class="modal-dialog " role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-3"></div>
                        <div class="col-md-5">
                            <div class="form-group">
                                <input type="text" class="form-control" id="chqNumber" placeholder="Cheque Number">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" id="chqAmount" placeholder="Cheque Value">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" runat="server" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="button" onclick="chqTransfer();" class="btn btn-primary">Save </button>
                </div>
            </div>
        </div>
    </div>





我尝试过:



我可以通过内容页面上的按钮触发此模式没有问题,但不是来自后面的代码,虽然alert()部分会触发。



希望有人有一些想法,因为我肯定不会....



What I have tried:

I can fire this modal no problem with a button on the content page, but not from code behind, although the alert() part does fire.

Hope someone has some idea as I surely don't ....

推荐答案

('#chqPayModal')。modal('show' );
}

< / script>
('#chqPayModal').modal('show'); } </script>





和模态代码: -





And the Modal code:-

<pre>   <div class="modal modal-dialog-centered fade " id="chqPayModal" tabindex="-1" role="dialog" aria-labelledby="chqPayModal" aria-hidden="true">
        <div class="modal-dialog " role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-3"></div>
                        <div class="col-md-5">
                            <div class="form-group">
                                <input type="text" class="form-control" id="chqNumber" placeholder="Cheque Number">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" id="chqAmount" placeholder="Cheque Value">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" runat="server" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="button" onclick="chqTransfer();" class="btn btn-primary">Save </button>
                </div>
            </div>
        </div>
    </div>





我尝试过:



我可以通过内容页面上的按钮触发此模式没有问题,但不是来自后面的代码,虽然alert()部分会触发。



希望有人有一些想法,因为我肯定不会......



What I have tried:

I can fire this modal no problem with a button on the content page, but not from code behind, although the alert() part does fire.

Hope someone has some idea as I surely don't ....


这篇关于从绝对失败的代码打开模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆