Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 要放入的内容在mvc3中部分继承了部分_Asp.net Mvc 3_Partial Views - Fatal编程技术网

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