Html 在屏幕右侧创建视图放置表
我有一个MVC项目,用户实体与地址有一对多关系 我首先使用代码,然后通过脚手架生成视图。在create操作中,我在屏幕左侧看到了从userid到使用的字段。我需要的是非常简单的,在create视图的屏幕右侧create表中,该表当前为空,其中有一列用户可以添加到address,我应该如何做 我是MVC的新手,在CREATEVIED的右侧没有找到任何关于如何添加控件类表格的文档 我尝试过这样的事情,但没有成功 表格位于屏幕底部Html 在屏幕右侧创建视图放置表,html,asp.net,asp.net-mvc,asp.net-mvc-4,razor,Html,Asp.net,Asp.net Mvc,Asp.net Mvc 4,Razor,我有一个MVC项目,用户实体与地址有一对多关系 我首先使用代码,然后通过脚手架生成视图。在create操作中,我在屏幕左侧看到了从userid到使用的字段。我需要的是非常简单的,在create视图的屏幕右侧create表中,该表当前为空,其中有一列用户可以添加到address,我应该如何做 我是MVC的新手,在CREATEVIED的右侧没有找到任何关于如何添加控件类表格的文档 我尝试过这样的事情,但没有成功 表格位于屏幕底部 @using (Html.BeginForm()) { @Ht
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>User</h4>
<hr />
@Html.ValidationSummary(true)
<div class="form-group">
@Html.LabelFor(model => model.UserId, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.UserId)
@Html.ValidationMessageFor(model => model.UserId)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.WorkingAt, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.WorkingAt)
@Html.ValidationMessageFor(model => model.WorkingAt)
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
//This is the table which I want to be in the right side of the screen
<table class="table">
<tr>
<th>
@Html.EditorFor(model => model.Adress)
</th>
</table>
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
@使用(Html.BeginForm())
{
@Html.AntiForgeryToken()
使用者
@Html.ValidationSummary(true)
@LabelFor(model=>model.UserId,新的{@class=“controllabel col-md-2”})
@EditorFor(model=>model.UserId)
@Html.ValidationMessageFor(model=>model.UserId)
@LabelFor(model=>model.WorkingAt,新的{@class=“controllabel col-md-2”})
@EditorFor(model=>model.WorkingAt)
@Html.ValidationMessageFor(model=>model.WorkingAt)
//这是我想放在屏幕右侧的桌子
@EditorFor(model=>model.address)
@ActionLink(“返回列表”、“索引”)
@节脚本{
@Scripts.Render(“~/bundles/jqueryval”)
}
试试这个:
<table class="table col-md-offset-11 col-md-10">
<tr>
<th>
@Html.EditorFor(model => model.Address)
</th>
</table>
@EditorFor(model=>model.Address)
实际上,这与MVC无关。请尝试使用适当的CSS控制视图。对于这种特殊情况,请尝试使用CSS属性,如:clear、float等。检查这些:,为什么不尝试使用@Html.Partial(“YourAddressView”,model.Address)。这可能会帮助你…谢谢,投票结果是向上的,我看到桌子的位置被改到了右边,我应该如何将它改为向上和向下,我希望它位于屏幕上方的右侧,当前是向下的