Part 48 Custom html helpers in mvc

In this video, we will discuss, creating custom html helpers. We will be using the example, that we worked with in Part 47. Please watch Part 47, before proceeding. In Part 47, to render the image, we used the following code. We are building the image tag, by passing values for “src” and “alt” attributes. [img src=”@Url.Content(@Model.Photo)” alt=”@Model.AlternateText” /] Though the above code is not very complex, it still makes sense to move this logic into it’s own helper method. We don’t want any complicated logic in our views. Views should be as simple as possible. Don’t you think, it would be very nice, if we can render the image, using Image() html helper method as shown below. Unfortunately, MVC does not have built-in Image() html helper. So, let’s build our own custom image html

It's only fair to share...Tweet about this on TwitterShare on FacebookShare on TumblrShare on Google+Digg thisShare on LinkedInPin on PinterestShare on VKShare on RedditPrint this pageEmail this to someone
Flattr the authorShare on StumbleUponShare on YummlyBuffer this page

Leave a Reply

Your email address will not be published. Required fields are marked *