我创建了一个局部视图,我将这部分用于另一个视图,它继承自_layout m代码是真的并且没有错误,但是当我点击提交时它显示以下消息:(资源不能是找到)。我无法追踪这个错误。请帮我 。谢谢 这是我的新闻.Cshtml:
@model MPortal.Models.WebSite_OpinionDB
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Body{
@Html.Partial("CreateOpinion")
@Html.Action("CreateOpinion", "User")
}
这是我的_Layout.cshtml:
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
<link href="~/Theme/css/bootstrap.css" rel="stylesheet">
<link href="~/Content/CssFramework.css" rel="stylesheet" />
@RenderSection("CSS", required: false)
</head>
<body>
@RenderSection("Body", required: false)
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Scripts/modernizr-2.5.3.js"></script>
<script src="~/Theme/js/bootstrap.js"></script>
@RenderSection("scripts", required: false)
</body>
</html>
这是我的Partialview :( CreateOpinion.cshtml)
@model MPortal.Models.WebSite_OpinionDB
@section Body{
<div class="" style="float: right; width: 75%">
@Html.Raw(Session["Right"])
@using (Html.BeginForm())
{
<div class="rateit" style="float: right; width: 25%">
<input type="text" maxlength="100" value="name" class="form-control" name="Values" id="NameFamily" />
<br />
<input type="text" maxlength="100" value="email" class="form-control" name="Values" id="Email" />
<br />
@Html.TextAreaFor(x => x.OpinionText, new { @class = "form-control", @placeholder = "opinion" })
<br />
<button class="btn btn-primary" type="submit">submit</button>
</div>
}
<div class="" style="width: 20%; height: 625px; border: 1px solid black; float: left">
@Html.Raw(Session["Left"])
</div>
</div>
<div class="" style="float: right; width: 75%">
@if (ViewData["Success"] != null)
{
<div class="alert alert-success alert-dismissable">
<button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
@(ViewData["Success"] != null ? ViewData["Success"].ToString() : "")
</div>
}
@if (ViewData["UnSuccess"] != null)
{
<div class="alert alert-danger bs-alert-old-docs">
<button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
@(ViewData["UnSuccess"] != null ? ViewData["UnSuccess"].ToString() : "")
</div>
}
</div>
}
这是我的部分观点行动:
[ChildActionOnly]
public ActionResult CreateOpinion(MPortal.Models.WebSite_OpinionDB saveop, FormCollection frm)
{
if (!string.IsNullOrEmpty(frm["Values"]))
{
int mtID = (int)MPortal_CL.Globals.GetParam("MetaDataID", 0);
MPortal.Models.WebSite_OpinionDB op = new MPortal.Models.WebSite_OpinionDB();
String[] texts = frm["Values"].Split(',');
.....
.......
}
答案 0 :(得分:1)
删除属性[ChildActionOnly]
如果这不起作用,请使用重载版本
@using (Html.BeginForm("CreateOpinion","ControllerName"))