0
我NewsSummary.ascx用來顯示新聞文章的摘要清單,下面的部分觀點:ASP.NET MVC2渲染它自己的控制器的局部視圖
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<AkwiMemorial.Models.Article>>" %>
<table>
<% foreach (var item in Model as IEnumerable<AkwiMemorial.Models.Article>)
{ %>
<tr>
<td>
<strong>
<%= Html.Encode(String.Format("{0:MMMM dd yyyy}", item.DateCreated)) %>
</strong>
</td>
<td>
<%= Html.Encode(item.Abstract) %>
</td>
<td>
<a class="link1"> <%= Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ })%></a>
</td>
</tr>
<% } %>
</table>
我的HomeController獲取的文章顯示,並且創建在呈現之前,Index.aspx的ViewData字典中的一個條目。局部視圖,然後內使用的Index.aspx與Html.RenderPartial作爲其模型通過如下新聞文章的列表呈現:
<% Html.RenderPartial("NewsSummary", ViewData["news"]); %>
現在,我已經有獲取由給定ID的新聞文章一NewsController。點擊代碼後,點擊NewsSummary局部視圖中每篇文章摘要的詳細信息鏈接,在我的HomeController中調用一個名爲Details的操作。我如何將此操作綁定到NewsController中的Details方法。我研究了Html.RenderAction,但無法確定它在這種情況下對我的工作方式。
任何想法或我接近這個錯誤的方式嗎?
謝謝你,謝謝你。 – 2011-02-15 15:57:50