Html.ActionLink in Partial View

Posted by olst on Stack Overflow See other posts from Stack Overflow or by olst
Published on 2010-03-11T21:14:27Z Indexed on 2010/03/13 19:15 UTC
Read the original article Hit count: 354

Hi.

I am using the following code in my master page:

<%  Html.RenderAction("RecentArticles","Article"); %>

where the RecentArticles Action (in ArticleController) is :

[ChildActionOnly]
    public ActionResult RecentArticles()
    {
        var viewData = articleRepository.GetRecentArticles(3);

        return PartialView(viewData);
    }

and the code in my RecentArticles.ascx partial view :

<li class="title"><span><%= Html.ActionLink(article.Title, "ViewArticle", new { controller = "Article", id = article.ArticleID, path = article.Path })%></span></li>

The problem is that all the links of the articles (which is built in the partial view) lead to the same url- "~/Article/ViewArticle" . I want each title link to lead to the specific article with the parameters like I'm setting in the partial view.

Thanks.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc