Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 情态形式显示为非情态形式_Asp.net Mvc - Fatal编程技术网

Asp.net mvc 情态形式显示为非情态形式

Asp.net mvc 情态形式显示为非情态形式,asp.net-mvc,Asp.net Mvc,新来的。我有Index.cshtml,其中的标签如下所示,通过按钮调用_ModalFormSample.cshtml @{ ViewBag.Title = "Home Page"; } <div class="row"> <div class="col-md-4"> <div class="btn-group" role="gro

新来的。我有Index.cshtml,其中的标签如下所示,通过按钮调用_ModalFormSample.cshtml

 @{
       ViewBag.Title = "Home Page";
  }
 <div class="row">
     <div class="col-md-4">
        <div class="btn-group" role="group" aria-label="..." style="padding-bottom: 15px;">
            <a href="@Url.Action("ModalFormSample", "Home", new {timeStamp = DateTime.UtcNow.ToString()})" class="btn btn-info showModal">Add Account</a>
        </div>
     </div>
 </div>
@{
ViewBag.Title=“主页”;
}
_ModalFormSample.cshtml

<div class="modal" id="modalFormSample" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Modal title</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                     <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <p>Modal body text goes here.</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary">Save changes</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

情态标题
&时代;
模态体文本在这里

保存更改 接近
我希望_ModalFormSample在单击“添加帐户”按钮时会显示为模式表单,但它没有显示


我错过了什么?我使用VS2019 C#.Net

当您想要动态显示
模态
时,您需要编写
js
代码来实现您想要的

  • 添加一个div,您可以在其中附加预期模式的response div。在这里,我添加了id为
    myModal
    的div
  • 编写
    .showmodel
    单击事件函数,如下所示。评论中有解释
  • //showModal按钮单击事件
    $(“.showmodel”)。单击(函数(e){
    //停止重定向到href url的步骤
    e、 预防默认值();
    //从href获取url
    让url=$(this.attr(“href”);
    //在myModal div中执行ajax调用并追加响应。
    $.ajax({
    url:url,
    成功:功能(响应){
    //在myModal div中追加响应
    $('#myModal').html(回复);
    //显示模态
    $('modalFormSample').modal('show');
    },
    数据类型:“html”
    });
    });
    
    当您想要动态显示
    模式时,您需要编写
    js
    代码来实现您想要的

  • 添加一个div,您可以在其中附加预期模式的response div。在这里,我添加了id为
    myModal
    的div
  • 编写
    .showmodel
    单击事件函数,如下所示。评论中有解释
  • //showModal按钮单击事件
    $(“.showmodel”)。单击(函数(e){
    //停止重定向到href url的步骤
    e、 预防默认值();
    //从href获取url
    让url=$(this.attr(“href”);
    //在myModal div中执行ajax调用并追加响应。
    $.ajax({
    url:url,
    成功:功能(响应){
    //在myModal div中追加响应
    $('#myModal').html(回复);
    //显示模态
    $('modalFormSample').modal('show');
    },
    数据类型:“html”
    });
    });
    
    
    
    那么这里发生了什么?它是否重定向到
    /Home/ModalFormSample
    url?那么这里发生了什么?它是否重定向到
    /Home/ModalFormSample
    url?如何将其用作整个应用程序中所有模式表单的代码段?然后您可能希望将其添加到应用程序中所有页面通用的
    布局
    页面中。如何将其用作整个应用程序中所有模式表单的代码段?然后您可能希望将其添加到应用程序中您的
    布局
    页面在应用程序的所有页面中都是通用的。