开发者

asp.net mvc invoke controller action from helper class

As i understand asp.net mvc 2 allows use to invoke an action directly without mvc futures. so instaed of:

<%Html.RenderAction

we can use:

 <%Html.Action

I'm using an Helper class to invoke the action but inside the helper class i cannot find the .Action attirbute:

    public static void CatalogList(this HtmlHelper helper, string text)
{
    helper.ac 
}

there is no Action, but it work inline in the aspx file:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>Category</h2>开发者_StackOverflow
<%Html.Action( %>

not sure what i'm doing wrong, i really like the call to be in the helper and not inline.

Thanks


You just need to add a using directive for the right namespace: "System.Web.Mvc.Html".

Html.RenderAction() is included in asp.net mvc 2 as well. The only difference between RenderAction() and Action() is that Action() returns the rendered action as a string while RenderAction() renders the action directly to the output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜