Asp.net mvc 3 要放入的内容在mvc3中部分继承了部分
我有我的控制器,我不知道我是否有正确的Asp.net mvc 3 要放入的内容在mvc3中部分继承了部分,asp.net-mvc-3,partial-views,Asp.net Mvc 3,Partial Views,我有我的控制器,我不知道我是否有正确的 [HttpGet] [NoCache] public ActionResult ListCommentsOnNews(int newsId, string newsComment) ??? { //code here with return } 在my Article.aspx视图中: <div class="news-comment-content" id="news-comment-content"> <% if
[HttpGet]
[NoCache]
public ActionResult ListCommentsOnNews(int newsId, string newsComment) ???
{
//code here with return
}
在my Article.aspx视图中:
<div class="news-comment-content" id="news-comment-content">
<% if (Model.Results != null)
{ %>
<% foreach (var newsItem in Model.Results.NewsComments)
{ %>
<% Html.RenderPartial("SetCommentOnNews", newsItem); %>
<%} } %>
</div>
我在newsItem部分中得到错误,指出它在当前上下文中不存在。
有人能帮我纠正一下吗?正如我从您发布的代码中推断的,问题在于您对模型的使用。您正在尝试使用模型属性,但操作不正确。请尝试以下操作:
<%
Model.CommentDate
%>
而不是
<%: newsItem.CommentDate %> //get error here
//此处出现错误
型号。虽然我想知道在控制器参数列表和Inherits=“System.Web.Mvc.ViewUserControl请,谢谢”SetNewsArticleViewModel(news,null)的返回类型中放置什么,但intellisense没有给我任何信息?谢谢,我仍然会遇到这个错误,我在文章视图中调用的partial是否正确?我必须传递什么?这是否正确?让我们来看看
<%
Model.CommentDate
%>
<%: newsItem.CommentDate %> //get error here