tagbuilder

ASP.NET MVC TagBuilder.SetInnerText() not setting the text correctly

So I am creating a HtmlHelper extension method and I have run into a problem when using TagBuilder.SetInnerText(). The helper outputs an option tag. Here is the source of the helper: public static string Option(this HtmlHelper helper, string value, string text, object htmlAttributes) { TagBuilder tagBuilder = new TagBuilder("o...

What is the difference, if any, between string.Format and TagBuilder in ASP.NET MVC?

Hello SO: I have a Html Helper file for my ASP.NET MVC application. The majority of them simply return a formatted string. Here is an example of one of my formatted string helpers: public static string Label(this HtmlHelper helper, string @for, string text) { return string.Format("<label for \"{0}\">{1}</label>", @for, text); } ...

internal ToMVCHmlString in TagBuilder

I am looking to write a few helpers in my own assembly modeled after the helpers in System.web.mvc. My problem is that I cannot use the call to Tagbuilder.ToMvcHtlString since it is internal. So if I return a string it wont be ready for asp.net 4 when it comes. I dont want to add anything to system.web.mvc as that is a given dll. ...

Why use TagBuilder instead of StringBuilder?

what's the difference in using tag builder and string builder to create a table in a htmlhelper class, or using the HtmlTable? aren't they generating the same thing?? ...

How would you refactor this Asp.net MVC 2 Html Helper?

Hi All, Quick question. How would you refactor this Asp.net MVC 2 HtmlHelper? Specifically would it make sense to use the TagBuilder class in this scenario? public static MvcHtmlString BusinessDisplayContacts(this HtmlHelper helper, string phone, string cellPhone, string fax, string website, string email, bool hide...

Can you control the order in which the TagBuilder class renders attribues?

I know this is kind of obsessive, but is there a way to control the order that the TagBuilder class renders the attributes of an HTML tag when you call ToString()? i.e. so that var tb = new TagBuilder("meta"); tb.Attributes.Add("http-equiv", "Content-Type"); tb.Attributes.Add("content", "text/html; charset=utf-...