Some thoughts about writing custom html helpers.
In our project everywhere you can find the html helpers used like this.
@Html.TextBoxFor(m => m.ApplicationSettings.ApplicationName, new { @class = "inp" })
We append the css class “inp” to almost every input type.
So what I’m doing is that Im creating extended html helpers that does this for me.
@Html.ExtendedTextBoxFor(m => m.ApplicationSettings.ApplicationOwnerCompanyName)
I’m also creating Html helpers for our blocks of html code that are used over and over through the project.
Example
@Html.ExtendedNotification(Model.FormPostResult)
Which renders error/success messages after a form has been posted
This means that the Html helper extensions are depending on the css and markup.
Is this good or bad?
Am I overusing Html helpers?
That’s exactly what HTML helpers are meant for, so yes this is a very good use of helpers.