HtmlHelper vs. partial view

I cannot decide whether to use htmlHelper or a partial view to solve my problem.

I would like to use the following code:

<div style="width: 500px; float: left;"> <div class="box effect2"> <span><a href="@Url.Action("someMethod", "somController")"> <img src="@Url.Content("~someurl)" /></a></span> </div> </div> 

Href parameters and images will be parameters.

What is the best way to do this?

+6
source share
1 answer

Use a partial view when you have a lot of markup. HTML helpers should be used to create only small parts of HTML. In this particular case, you are really on the limit, and both approaches will be in order. Use the one you prefer for this particular example. I would probably go with a special HTML helper, as this seems to be quite common widgets that can be reused in different applications if you include it in the assembly.

+9
source

All Articles