Creating MVC3 Razor Helper like Helper.BeginForm()
says that it can be done using extension methods and implementing IDisposable. Can the same be done by using declarative Razor helpers eg. @helper SomeHelper(){}?
Creating MVC3 Razor Helper like Helper.BeginForm() says that it can be done using extension
Share
Sort of.
Razor helpers return raw HTML, not
IDisposable, so you can’t use it withusing.However, you can create a Razor helper in
App_Codeto render the content, then call it from a normal extension method that writes the content directly to the page and returns a separateIDisposable.