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 →

    3 comments

    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...
      • Matt HudsonMatt Hudson commented  ·   ·  Flag as inappropriate

        WHY.. in VB.Net do you prevent anyone who creates their own helpers from using any of the built in ones? This doesn't happen in C#. The fact that I can use both is one of the most useful features to me, and the fact that microsoft has not only removed this feature, but left no solutions, workarounds or documentation I find appauling.
        Why the developers of MVC chose to create the C# version as a nice, usually-easy, implementation. Then just crap all over the VB.NET version, completely ignoring and breaking core functionality. And then refusing to document any of it! Literally WTF. Half way through a project, custom helpers being a necessity to us, to find that now we then can't use the shiny new USEFUL Html.EditorFor and Html.DisplayFor in views if we add our own helpers. It's been over 5 years and not the slightest hint of a f*#! given about this issue by Microsoft. If I could use C# I would, this is a company limitation.

      • 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