Is there a way to make helper in Asp.Net MVC to wrap other html like this:
<div class="lightGreyBar_left">
<div class="lightGreyBar_right">
<!--Content-->
<h3>
Profiles</h3>
<div class="divOption">
<%= Html.ActionLinkWithImage("Create new", "add.png", Keys.Actions.CreateProfile, "add")%>
</div>
<!--Content-->
</div>
</div>
So that helper will render containing divs and content that is passed to helper method as parameter.
Have a look at the forms helper methods. They provide syntax like this:
The pattern for implementing this sort of HTML helpers is slightly more involved than the usual “just return a HTML string” type helpers. Basically, your helper method will
Response.Writethe opening tag(s) when it is called and return some custom object that implementsIDisposable. When the return value is disposed, it shouldResponse.Writethe closing tag(s).Here is a working example:
This will allow you to rewrite your view to this: