Reputation: 20569
I have this helper in my view:
<%= Html.StandardOverlayCreateButton<EmployeeController>()%>
It creates the following HTML:
<a rel="#overlay" href="/Employee/Create">
<button type="button">
Create</button>
</a>
I do not like this anyway.
Any suggestions :) ?
I also askmyself when to create html helper extension and when just write the pure HTML code?
Upvotes: 1
Views: 394
Reputation: 4108
I don't see why specifiying the controller in the HTML helper function isn't great. It will help with refactoring as it's strongly typed and it'll help get intellisense.
As for the extension / write html argument ... if you are going to use the same functionality again and again, write the HTML helper extension method :-)
Hope this helps.
Upvotes: 2
Reputation: 532745
In this case I think the helper is warranted as the amount of HTML "code" you're replacing is significant and conceptually a single entity, i.e., a styled "button". You can get access to the controller, however, in the view by using the ViewContext property on the ViewPage.
Upvotes: 1