I suggest you ...

Support @helper ExtensionMethod(this HtmlHelper html) for views in APP_CODE

Support creating extension methods with the @helper razor syntax, inside the APP_CODE folder.

This could be very useful, when creating html helpers, like the following code:

@helper ExtensionMethod(this HtmlHelper html, string data, string action)
{
<text>
<div>@data</div>
should I want to use Html here it is fine:
@html.ActionLink("Link text", action)
should I want to use Url here...
@{var url = new UrlHelper(html.ViewContext.RequestContext)}
@url.Action(action)
</text>
}

And be called inside any other view like this:

@Html.ExtensionMethod("Some text", "MyAction")

That'd be awesome! An easy way to make Html helpers!!!

33 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Miguel Angelo Santos BicudoMiguel Angelo Santos Bicudo shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Miguel Angelo Santos BicudoMiguel Angelo Santos Bicudo commented  ·   ·  Flag as inappropriate

        Suggestion on how to solve: invent a @static razor keyword, that cannot be used with @inherits... and that would tell that there is no base class, and that the class is static.

      Feedback and Knowledge Base