コントローラがパーシャルビューを返すという問題が発生しています。
これは私のコントローラーがどのように見えるかです:
[HttpPost]
public ActionResult ProcessSubmit(IEnumerable<HttpPostedFileBase> attachments, Models.FloorPlan.FloorPlanModel F)
{
F.FloorPlanList = null;
if (ModelState.IsValid)
{
//if (Models.FloorPlan.Repository.FloorPlanMethods.AddFloorPlan(F))
//{
if (attachments != null && attachments.Count() == 1)
{
foreach (var file in attachments)
{
// Some browsers send file names with full path. We only care about the file name.
var fileName = Path.GetFileName(file.FileName);
var destinationPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);
file.SaveAs(destinationPath);
F.Photo = destinationPath;
Models.FloorPlan.Repository.FloorPlanMethods.AddFloorPlan(F);
}
}
//}
}
Mvc.Models.FloorPlan.FloorPlanModel _floorPlanModel = new Models.FloorPlan.FloorPlanModel();
_floorPlanModel.FloorPlanList = Mvc.Models.FloorPlan.Repository.FloorPlanMethods.GetFloorPlansAll(F.PropertyID);
_floorPlanModel.PropertyID = F.PropertyID;
return PartialView("~/Views/FloorPlan/Index.cshtml", _floorPlanModel);
//return View("~/Views/FloorPlan/Index.cshtml", _floorPlanModel);
}
これは私のビューがどのように見えるかです:
@model Web.CMS.Mvc.Models.FloorPlan.FloorPlanModel
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@using (Html.BeginForm("ProcessSubmit", "FloorPlan", FormMethod.Post, new { id = "uploadForm", encrypt = "multipart/form-data" }))
{
@Html.ValidationSummary(false, "Please fix these errors.")
<div class="H1">
Floor Plans & Pricing
</div>
<!--<div class="iconAdd fl pt5 w120" onclick="FloorPlan_AddFloorPlan(); return false;">
<a></a>
</div>//-->
<div class="fl clr" style="width: 600px;">
<ul class="fl">
<li class="w110">Name </li>
<li class="w110">Beds </li>
<li class="w110">Baths </li>
<li class="w110">Sq Ft </li>
<li class="w110">Price</li>
<li class="w110">Text </li>
<li class="w110">Photo </li>
</ul>
<ul class="fl">
<li>@Html.TextBoxFor(f => f.Name)</li>
<li>@Html.TextBoxFor(f => f.Bedrooms)</li>
<li>@Html.TextBoxFor(f => f.Bathrooms)</li>
<li>@Html.TextBoxFor(f => f.SquareFeet)</li>
<li>@Html.TextBoxFor(f => f.Price)</li>
<li>@Html.TextBoxFor(f => f.Body)</li>
<li>@Html.TextBoxFor(f => f.Photo)
@(Html.Telerik().Upload()
.Name("attachments")
.Multiple(false)
)
<div class="iconBrowse fr pt5"></div>
<input type="submit" value="Send" class="t-button" />
<input type="reset" value="Reset" class="t-button" />
</li>
</ul>
</div>
<br />
<div class="clr">
<input type="button" onclick="javascript: FloorPlan_AddFloorPlan(); return false;" value="Save" />
@(Html.Telerik().Grid(Model.FloorPlanList)
.DataKeys(k => k.Add(o => o.FloorPlanID))
.DataBinding(dataBinding => dataBinding
.Ajax()
.Select("Index", "Home")
.Delete("Delete", "FloorPlan"))
.Name("FloorPlanListGrid")
.Scrollable()
.Pageable()
.Selectable()
.Columns(col =>
{
col.Bound(c => c.Name);
col.Bound(c => c.Photo);
col.Bound(c => c.Body);
col.Bound(c => c.Bedrooms);
col.Bound(c => c.Bathrooms);
col.Bound(c => c.Price);
col.Bound(c => c.SquareFeet);
col.Command(commands =>
{
commands.Delete();
}).Width(100);
})
)
@Html.HiddenFor(x => x.PropertyID)
</div>
}
<script src="@Url.Content("~/Scripts/floorplan.index.debug.js")" type="text/javascript"></script>
結果のページには、ビューの「Form」タグの後の実際のデータのみが含まれます。