0

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

模型形式

但是 Entity FrameWork 将所有视图与菜单和页脚一起带入,就像这样。

在此处输入图像描述

如何删除视图的菜单和页脚并且只有字段和标签?

风景

    @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>
}

拉伸控制器

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();

});

我在实体框架中开发。

谢谢你的帮助!

4

1 回答 1

0

返回 aPartialView而不是View

public PartialViewResult Details(int id)
        {
            User user = context.User.Single(x => x.UserId == id);
            return PartialView("Details", user);
        }
于 2013-11-01T17:16:45.087 回答