本文介绍了如何使用返回局部视图对窗口进行poulate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看

----

View
----

@Html.ActionLink("Register here", "RegisterUser", "login", null, new { @class = "openDialog", data_dialog_id = "aboutdialog", data_dialog_title = "register new user" })





Controler

----------



Controler
----------

[HttpGet]
    public ActionResult RegisterUser()
    {
        return PartialView("_Register");
    }





_Layout Page



_Layout Page

<script type="text/javascript">
        //function SavedData(data) {
        //    $(".dialog").dialog("close");
        //}
        //function ErrorSave(data) {
        //    alert(data.parsetext);
        //}
        //function BeginReq(data) {
        //    $.validator.unobtrusive.parse('#registerform');
        //}
        $(document).ready(function () {
            alert("hi");
            debugger;
            $(".openDialog").on("click", function (e) {
                alert("BBH");
                e.preventDefault();

                $("<div></div>").addClass("dialog").attr("id", $(this).attr("data-dialog-id")).appendTo("body").dialog({
                        title: $(this).attr("data-dialog-title"),
                        close: function () { $(this).remove(); },
                        modal: true,
                        width: 600,
                        left: 0,
                    })
                .load(this.href);
            });



            $(".close").on("click", function (e) {
                e.preventDefault();
                $(this).closest(".dialog").dialog("close");
            });
        })
    </script>





_partial view:_Register.cshtml

--------------------------------



_partial view: _Register.cshtml
--------------------------------

@model MVC_ERP_APP.Models.RegisterUser


@using (Ajax.BeginForm("RegisterUser", "Login", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "PopUpDiv", OnBegin = "BeginReq", InsertionMode = InsertionMode.Replace, OnSuccess = "SavedData", OnFailure = "ErrorSave" }, new { ID = "registerform" }))
{
    <fieldset>
        <legend>New User</legend>
        <table class="table-bordered">
            <tr>
                <td>
                    @Html.LabelFor(model => model.username)
                </td>
                <td>
                    @Html.TextBoxFor(model => model.username)
                    @Html.ValidationMessageFor(model => model.username)
                </td>
            </tr>

            <tr>
                <td>
                    @Html.LabelFor(model => model.password)
                </td>
                <td>
                    @Html.TextBoxFor(model => model.password)
                    @Html.ValidationMessageFor(model => model.password)
                </td>
            </tr>

            <tr>
                <td>
                    @Html.LabelFor(model => model.RegDate)
                </td>
                <td>
                    @Html.TextBoxFor(model => model.RegDate)
                    @Html.ValidationMessageFor(model => model.RegDate)
                </td>
            </tr>

            <tr>
                <td>
                    @Html.LabelFor(model => model.email)
                </td>
                <td>
                    @Html.TextBoxFor(model => model.email)
                    @Html.ValidationMessageFor(model => model.email)
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" value="Register" />
                </td>
            </tr>
        </table>
    </fieldset>
}







错误

-----

未捕获TypeError:对象[object Object]没有方法'对话'



问候

Basheer Ahamed.B




Error
-----
Uncaught TypeError: Object [object Object] has no method 'dialog'

Regards
Basheer Ahamed.B

推荐答案




这篇关于如何使用返回局部视图对窗口进行poulate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 23:07