<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Dave Arlin - Bloggin' - HTMLHelper</title>
    <link>http://blog.davearlin.com/</link>
    <description>learn forever</description>
    <language>en-us</language>
    <copyright>Dave Arlin</copyright>
    <lastBuildDate>Sat, 01 May 2010 03:17:20 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>dave@davearlin.com</managingEditor>
    <webMaster>dave@davearlin.com</webMaster>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=51f1b932-abc5-441c-a251-fd9e76a3130b</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,51f1b932-abc5-441c-a251-fd9e76a3130b.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,51f1b932-abc5-441c-a251-fd9e76a3130b.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=51f1b932-abc5-441c-a251-fd9e76a3130b</wfw:commentRss>
      <title>A Simple Extension of ASP.NET MVC HTMLHelper</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,51f1b932-abc5-441c-a251-fd9e76a3130b.aspx</guid>
      <link>http://blog.davearlin.com/2010/05/01/ASimpleExtensionOfASPNETMVCHTMLHelper.aspx</link>
      <pubDate>Sat, 01 May 2010 03:17:20 GMT</pubDate>
      <description>&lt;p&gt;
If you’re an ASP.NET MVC developer, you’ve almost undoubtedly used HTML helpers, or
at least the built in ones.
&lt;/p&gt;
&lt;p&gt;
Here’s are some common ones:
&lt;/p&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:dd5bed22-7ed2-403a-bfb6-3240e8b79eca" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;Html.DropDownList(&lt;span style="color:#a31515"&gt;"Countries"&lt;/span&gt;,&lt;span style="color:#a31515"&gt;"Choose Country"&lt;/span&gt;)&lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
This generates a DropDownList populated with the property “Countries” of type “SelectList”
on the ViewData model passed into the view.
&lt;/p&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51c88f73-5b3f-4406-9cd9-1f530966da05" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;Html.TextBox(&lt;span style="color:#a31515"&gt;"EntitySearch"&lt;/span&gt;)&lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
This generates a TextBox bound to the property “EntitySearch” on the ViewData model
passed into the view. Can also be used to populate a property with the same name upon
a form post.
&lt;/p&gt;
&lt;p&gt;
In my current project, I’ve found the need to have many different buttons. These buttons
are custom in the sense that they aren’t the standard HTML buttons, they have CSS
and/or images associated with them. Here’s how I might declare a couple of them right
now:
&lt;/p&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0b9ca86d-91c9-45c3-8435-2c5673dfd48d" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;input&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt; &lt;span style="color:#0000ff"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff"&gt;"image"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;class&lt;/span&gt; &lt;span style="color:#0000ff"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff"&gt;"addnew-button"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e9bf5f35-42a4-4c41-a11e-a44cddd9e09a" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;Html.SubmitImage(&lt;span style="color:#a31515"&gt;"Submit"&lt;/span&gt;,&lt;span style="color:#a31515"&gt;"~/images/submit-button.png"&lt;/span&gt;) &lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
So in both cases, I have to type in a string that kind of defines my button. In the
first example, I have to say my button is an “image” and the class to use to style
the button is called “addnew-button”. 
&lt;/p&gt;
&lt;p&gt;
In the second case, I have to define the actual path to the button. It’d be nice to
have a more common and type safe way to declare all of my buttons, so I’ve created
a Button HtmlHelper method. My goal is to be able to have code in my view like this:
&lt;/p&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e39b116f-0af4-4342-85f3-105801b63541" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;Html.Button(&lt;span style="color:#2b91af"&gt;ButtonHtmlHelper&lt;/span&gt;.&lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.AddNew) &lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:864e5d23-a0c8-4be6-890a-2fac78aea2e9" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;Html.Button(&lt;span style="color:#2b91af"&gt;ButtonHtmlHelper&lt;/span&gt;.&lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Submit) &lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
To do this, I created an extension method on the HtmlHelper class called button. This
extension method can handle all my button types and has some overloads to accept a
client id and any additional custom styling.
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c011331e-a3bc-4b87-b9e4-173928a1ff9c" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; MyProject.HtmlHelpers&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonHtmlHelper&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;enum&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt; {
AddNew, Remove, Ok, Cancel, Submit, Save, Search, Clear, Continue, Active, Inactive
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Button(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HtmlHelper&lt;/span&gt; htmlHelper, &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt; buttonType)&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; Button(htmlHelper, buttonType, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Button(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HtmlHelper&lt;/span&gt; htmlHelper, &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt; buttonType, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; id)&lt;/li&gt;
&lt;li&gt;
{&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; Button(htmlHelper, buttonType, id, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Button(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HtmlHelper&lt;/span&gt; htmlHelper, &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt; buttonType, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; id, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; inlineCSS)&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#2b91af"&gt;StringBuilder&lt;/span&gt; addNewButtonHTML = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;StringBuilder&lt;/span&gt;();&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
addNewButtonHTML.Append(&lt;span style="color:#a31515"&gt;@"&lt;input class= """&lt;/span&gt;);
&lt;/li&gt;
&lt;li&gt;
addNewButtonHTML.Append(GetButtonTypeCSSClassPrefix(buttonType));&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
addNewButtonHTML.Append(&lt;span style="color:#a31515"&gt;@"-button"" type = ""image"" "&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (!&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.IsNullOrEmpty(id))&lt;/li&gt;
&lt;li&gt;
addNewButtonHTML.AppendFormat(&lt;span style="color:#a31515"&gt;@"id = ""{0}"" "&lt;/span&gt;,
id);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (!&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.IsNullOrEmpty(inlineCSS))&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
addNewButtonHTML.AppendFormat(&lt;span style="color:#a31515"&gt;@"style = ""{0}"" "&lt;/span&gt;,
inlineCSS);&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
addNewButtonHTML.Append(&lt;span style="color:#a31515"&gt;"/&gt;"&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; addNewButtonHTML.ToString();&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; GetButtonTypeCSSClassPrefix(&lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt; buttonType)&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;switch&lt;/span&gt; (buttonType)&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.AddNew:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"addnew"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Cancel:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"cancel"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Ok:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"ok"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Remove:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"remove"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Submit:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"submit"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Save:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"save"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Search:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"search"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Clear:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"clear"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Continue:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"continue"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Active:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"active"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Inactive:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"inactive"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;default&lt;/span&gt;:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ArgumentException&lt;/span&gt;(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;"Unknown
ButtonType of {0} was passed in."&lt;/span&gt;, buttonType));&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
That’s all! Just make sure you either add a using statement on the view to the namespace
where the HTMLHelper is, or put it in the web.config like I did in my project. (line
10)
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9551f6e6-3c3d-4700-972a-a56682c04e0a" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;namespaces&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Web.Mvc&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Web.Mvc.Ajax&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Web.Mvc.Html&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Web.Routing&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Linq&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Collections.Generic&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;Microsoft.Web.Mvc&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;xVal.Html&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;MyProject.HtmlHelpers&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;namespaces&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=51f1b932-abc5-441c-a251-fd9e76a3130b" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,51f1b932-abc5-441c-a251-fd9e76a3130b.aspx</comments>
      <category>ASP.Net MVC</category>
      <category>HTMLHelper</category>
    </item>
  </channel>
</rss>