I can't decide whether I should use a htmlHelper or a partial view for solving my problem.
I would like to reuse 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>
The href and the image source would be parameters.
What is the best way to do it ?
Use partial view when you have lots of markup. Html helpers should be used to generate only small portions of HTML. In this particular case you are really on the limit and both approaches would be fine. Use the one you prefer for this particular example. I'd probably go with a custom HTML helper here as this seems quite a common widget that could be reused across various applications if you incorporate it into an assembly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With