仅恢复视图的一部分

时间:2013-11-01 17:11:45

标签: jquery asp.net-mvc razor webforms entity-framework-5

我正在尝试开发一个模型表单并在其中插入我的视图,就像这样。

Model form

但是Entity FrameWork带有菜单和页脚的所有视图,就像这样。

enter image description here

如何删除菜单和页脚视图,并且只包含字段和标签?

视图

    @model TPTMVC.Models.User
@using TPTMVC.Models;

@{
    ViewBag.Title = "Details";
}

<h2>Details</h2>
@using (@Html.BeginForm())
{ 

    <fieldset>
        <legend>User</legend>

        <div class="display-label">FirstName</div>
        <div class="display-field">@Model.FirstName</div>

        <div class="display-label">LastName</div>
        <div class="display-field">@Model.LastName</div>

        <div class="display-label">Number</div>
        <div class="display-field">@((Model.billingDetail).Number)</div>

        <div class="display-label">Owner</div>
        <div class="display-field">@((Model.billingDetail).Owner)</div>


    </fieldset>
}

Tretch控制器

public ViewResult Details(int id)
        {
            User user = context.User.Single(x => x.UserId == id);
            return View(user);
        }

将视图插入模型表单

链接

@Html.ActionLink("Details", "Details", new { id = item.UserId }, new { @class = "Details" })

Jquery的

$(".Details").live(
    "click", function (e) {
    // e.preventDefault(); use this or return false
    var url = $(this).attr('href');

    $("#dialog-view").dialog({
        title: 'Detail User',
        autoOpen: false,
        resizable: false,
        height: 250,
        width: 400,
        show: {
            effect: 'drop',
            direction: "up"
        },
        modal: true,
        draggable: true,
        open: function (event, ui) {
            $(this).load(url);
        },
        buttons: {
            "Close": function () {
                $(this).dialog("close");
            }
        },
        close: function (event, ui) {
            $(this).dialog('close');
        }
    });

    $("#dialog-view").dialog('open');

    return false;

    e.preventDefault();

});

我在实体框架中发展。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

返回PartialView而不是View

public PartialViewResult Details(int id)
        {
            User user = context.User.Single(x => x.UserId == id);
            return PartialView("Details", user);
        }