Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC2 rendering a partial view with its own controller
    primarykey
    data
    text
    <p>I have the following partial view NewsSummary.ascx used to display a list of news article summaries:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;IEnumerable&lt;AkwiMemorial.Models.Article&gt;&gt;" %&gt; &lt;table&gt; &lt;% foreach (var item in Model as IEnumerable&lt;AkwiMemorial.Models.Article&gt;) { %&gt; &lt;tr&gt; &lt;td&gt; &lt;strong&gt; &lt;%= Html.Encode(String.Format("{0:MMMM dd yyyy}", item.DateCreated)) %&gt; &lt;/strong&gt; &lt;/td&gt; &lt;td&gt; &lt;%= Html.Encode(item.Abstract) %&gt; &lt;/td&gt; &lt;td&gt; &lt;a class="link1"&gt; &lt;%= Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ })%&gt;&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;% } %&gt; &lt;/table&gt; </code></pre> <p>My HomeController fetches articles to be displayed and creates an entry in the ViewData dictionary of Index.aspx before it is rendered. Partial view is then rendered within Index.aspx using Html.RenderPartial with the lists of news articles passed as its model as follows:</p> <pre><code>&lt;% Html.RenderPartial("NewsSummary", ViewData["news"]); %&gt; </code></pre> <p>Now, I already have a NewsController that fetches a news article by a given Id. With the code as as, clicking on the Details link of each article summary in the NewsSummary partial view invokes an action in my HomeController called Details. How do I tie this action to the Details method in my NewsController. I looked into Html.RenderAction but could not determine how it will work for me in this scenario. </p> <p>Any ideas or am I approaching this the wrong way?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload