伙计们,我曾尝试使用多个具有单一视图的模型。
但我找不到如何实现它的解决方案。
我想在过去的单一视图中使用一个视图数据,而在另一部分中使用另一个视图数据..
我使用了以下代码..
这是一种观点
@Html.Partial("Sidebar")
这是另一种观点
<!-- start content -->
<div id="content">
<div class="post">
<h1 class="title">
Add New Post
</h1>
<p></p>
<div class="entry">
@using (Html.BeginForm())
{
<div>
<div style="display:inline;">
<div style="display: inline; float: left;">
@Html.Label("lblcategory", "Category", new { style = "Width:100px; float: left;" })
<div style="width: 150px; height: 60px; overflow-y: scroll; display: inline; float: left;">
@for (int i = 0; i < (int)TempData["Rows"]; i++)
{
for (int j = 0; j < (int)TempData["Cols"]; j++)
{
<input id="Checkbox + @i" name = "Category" type="checkbox" style="width:50px;" value="@TempData["[" + i.ToString() + "][" + j.ToString() + "]"]"/>
@TempData["[" + i.ToString() + "][" + j.ToString() + "]"]
}
}
@*@Html.LabelFor(model => model.CategoryName)*@
</div>
<div style="float:right;">
<label id="lblcategoryrequired" style="color:Red">@Html.ValidationMessageFor(model => model.CategoryName)</label>
</div>
</div>
</div>
<div>
<p style="display: inline; float: left;">
@Html.Label("lblsubjet", "Subject", new { style = "Width:100px; float: left;" })
@*@Html.TextBox("txtsubject", "", new { style = "Width:700px;" })*@
@Html.TextBoxFor(model => model.PostSubject, new { style = "Width:400px; maxlength=400;" })
<label id="lblsubjectrequired" style="color:Red">@Html.ValidationMessageFor(model => model.PostSubject)</label>
</p>
</div>
<div>
<p style="display: inline; float: left;">
@Html.Label("lblcontent", "Content", new { style = "Width:100px; float: left; Vertical-align:top;" })
@*@Html.TextArea("txtcontent","", new { style = "Width:700px; height:200px; maxlength=700;" })*@
@Html.TextAreaFor(model => model.PostContent, new { style = "Width:400px; height:200px; maxlength=400;" })
</p>
</div>
<div>
<p style="display: inline; float: left;">
@Html.Label("lblblank", "a", new { style = "Width:100px; float: left; Color:#372412" })
<input type="submit" value="Add" id="btnadd" style="width: 100px;" class="button" />
    
<a id="Cancel" href="~/Home/Home"> <input type="button" value="Cancel" id="btncancel" class="button" style="width: 100px;" /></a>
</p>
</div>
</div>
@Html.ValidationSummary(true)
}
</div>
</div>
</div>
</div>