在MVC4中打开模型弹出窗口

时间:2013-05-28 05:47:17

标签: jquery asp.net-mvc asp.net-mvc-4

我想从mvc4中的视图中打开一个模型弹出窗口。该弹出页面的Sceenshot是enter image description here>

我不知道如何在MVC中打开模型弹出窗口?

目前我正在使用window.showmodeldialog,但它效率不高。我用google搜索它,但无法找到合适的结果。我打开弹出窗口的当前页面的代码是: -

@{
    Layout = null;
}



<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Claim Audit Admin </title>
    @*  @Styles.Render("~/Content/logincss")
    @Styles.Render("~/Content/workbenchcss")
    @Styles.Render("~/Content/appFramecss")*@
    <link href="~/Content/workbench.css" rel="stylesheet" />
    <link href="~/Content/style.css" rel="stylesheet" />
    <link href="~/Content/Button.css" rel="stylesheet" />
    <link href="~/Content/TabbedSection.css" rel="stylesheet" />
    <link href="~/Content/search.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/searchFirefox.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/normalize.css" rel="stylesheet" type="text/css" />
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript">
        var staticURL = "https://static-dev.mymitchell.com";
        var NoResultMsg = "";
        function enableButton() {
            button.disableSpinner('#spinnertest');
            button.disableSpinner('#Smallbtn');
        }

      $(function () {
            applyFilter(true);
            toggleSelectBtnOnCheck();

            $('#CreateSet').click(function (e) {
                openPopup();
            });
        });

        function toggleSelectBtnOnCheck() {
            //Register checkbox click handler to be called when Ajax requests complete.
            $('.searchResultTable').ajaxComplete(function () {
                $(':checkbox').click(function () // Bind the following anonymous function to all checkboxes click event.
                {
                    //Check if any checkbox is checked...
                    if ($('input:checkbox:checked').length > 0) {
                        button.enable('#btnDelete');
                    }
                    else {
                        button.disable('#btnDelete');
                    }
                });
            });
        }

         function openPopup() {
            var url = "/ClaimAuditAdmin/CreateNewSet/";
            var vReturnValue = openModalWindow(url, 'Create New Claims Audit Set', '300', '150', 'no');
        }

        //This function is used to open any page as modal popup
        function openModalWindow(sPage, sTitle, iWidth, iHeight, bScroll) {

            var sModalPage = sPage;
            if (sPage.indexOf("?") > 0) {
                sModalPage += "&";
            } else {
                sModalPage += "?";
            }
            sModalPage += "title=" + sTitle
            sWinProps = 'scroll:no; status: no; help: no;dialogWidth:19;dialogHeight:12;';

            var vRetVal = window.showModalDialog(sModalPage, window, sWinProps)

            return vRetVal;
        }

        function blurOn() {
            if (document.all.item("screenBlur") != null) {
                document.all.screenBlur.style.display = '';
            }
        }

        function blurOff() {
            if (document.all.item("screenBlur") != null) {
                document.all.screenBlur.style.display = 'none';
            }
        }

    </script>

    <script src="http://localhost/static/jquery/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
    <script src="http://localhost/static/jquery/jquery-ui/1.8.23/jquery-ui.min.js" type="text/javascript"></script>
    <script src="~/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    <script src="~/Scripts/searchresults.js"></script>
    <script src="~/Scripts/search.js" type="text/javascript"></script>
</head>
<body>
    <table>
        <tr>
            <td class="breadcrumbs">
                @Html.Mitchell().BreadCrumb().AddCrumb(@CultureAPI.GlobalizeString("ClaimsAuditAdmin", "UAM_MANAGE_CLAIM_AUDIT"))
            </td>
        </tr>
        <tr>
            <td style="text-align: right">
                **@Html.Mitchell().Button().Name("CreateSet").Text(@CultureAPI.GlobalizeString("ClaimsAuditAdmin", "STATIC_CREATE_NEW_SET")).Enabled(true)**
            </td>
            <td></td>
        </tr>

        <tr>
            <td>

                <div>
                    @(Html.Mitchell().SearchResult("SearchResult", "../UnsentQueueService2.asmx/GetData")
                        .AddFilterSection("_ClaimAuditAdminView", "Filter")
                        .ExpandCriteria()
                        .ShowTopCap()
                        .HighlightRow()
                        .ShowCheckBoxes()
                        .AddFooterSection(@<text>
                    <table>
                        <tr>
                            <td>
                                @(Html.Mitchell()
                                .Button().Name("btnDelete").Text("Delete").Enabled(false)
                                )
                            </td>
                        </tr>
                    </table>
                    </text>)
                        )
                </div>
            </td>
        </tr>
    </table>

</body>

</html>

因为我是mvc的新手,有人能为我提供一些在mvc4中打开模型弹出窗口的链接吗?

2 个答案:

答案 0 :(得分:2)

您可以使用this开源。 我在我的ASP.NET MVC4项目中使用它,这是非常好的方法。

答案 1 :(得分:2)

您可以使用jquery UI对话框。我在我的项目中使用它们并且它们很好。 看一看。 http://jqueryui.com/dialog/