简体   繁体   English

在Request []之后显示引导程序模态

[英]show bootstrap modal after Request[]

I'm trying to make a modal with bootstrap in mvc4 . 我正在尝试在mvc4使用bootstrap进行模态mvc4 But whenever I call a Request[] the form disappears. 但是,每当我调用Request []时,表格就会消失。

I've tried this: 我已经试过了:

@{
    bool show = false;

    if(Request["btn"] == "click here")
    {
        show = true;
    }
}

<a href="#" data-toggle="modal" data-target="#form_login">Login</a>
<div class="modal fade" id="form_login" role="dialog" aria-labelledby="form_loginLabel" 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="form_loginLabel">Test form</h4>
            </div> <!-- class="modal-header" -->

            <form action="" method="post">
                <div class="modal-body">
                </div> <!-- class="modal-body" -->

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <input type="submit" value="Login" name="btn" id="login_submit" class="button" />
                </div> <!-- class="modal-footer" -->
            </form>
        </div> <!-- class="modal-content" -->
    </div> <!-- class="modal-dialog" -->
</div> <!-- id="form_login" -->

<script>
    @{
        if(showModal)
        {
            $('#form_login').modal("show");
        }
    }
</script>

This doesn't work however. 但是,这不起作用。 What would be a good way to solve this problem. 什么是解决此问题的好方法。

I found the solution. 我找到了解决方案。

This has to be edited: From 必须对此进行编辑:从

<script>
    @{
        if(showModal)
        {
            $('#form_login').modal("show");
        }
    }
</script>

Into 进入

<script>
    @{
        if(showModal)
        {
            <text>$('#form_login').modal("show");</text>
        }
    }
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM