mvc getting html programitically in view mvc getting html programitically in view

What is the best way to get HTML programmatically in the view from the controller. I sometimes use string builder for that to render some html and send it the view from the it efficient?

What do you people suggests?

Having POCOs, Entities and ViewModels in a solution feels like overkill

1: mvc html Drop down list helper isn't selecting option
HtmlHelpers are meant for that. MasterPage equivalent in Ruby on Rails, Trying to define a site wide layoutA better option is to create an HtmlHelper this will generate the tag you you need and all you did is pass an object to it (from the Model or ViewData in the view) and it outputs the proper tag for you. ASP.NET MVC 2 and ComponentModel.DataAnnotations Validation: minimum value attributeThere is a TagBuilder object this will streamline everything you need.. Best custom dynamic grid for MVC [closed]
public static string MyHtmlHelper(this HtmlHelper html, string url) {        TagBuilder tag = new TagBuilder("a");        tag.Attrialthough es.Add("href", url);        return tag.ToString(); } 
Then in your view:. mvc jquery paging plugin
<%= Html.MyHtmlHelper(ViewData["MyUrl"].ToString()) %> 
This is just a quick example, you must extrapolate it to your liking. jQuery + MVC . System.accessviolationexception Attempted to read or write protected memory. This is often an indication that other memory is corrupt Search mvc html helpers to understand how this works and how extension methods work..


There is nothing wrong with assembling HTML using a StringBuilder and rendering it in a view, as long as you correctly escape it.. However, it's poor design. The controller should be ignorant of the presentation; all of the HTML should be in the view(s). What are you endeavor to do?.

51 out of 100 based on 56 user ratings 211 reviews