title: Adding a custom HTML Helper to MVC Project
body: <p>I've been browsing the web trying to find a good example/tutorial detailing how I can create and use my own custom HTML Helpers for my MVC 3 Razor application I found this one which is as follows</p>
  
  <p><a href="https://stackoverflow.com/questions/5052752/adding-your-own-htmlhelper-in-asp-net-mvc-3">Adding your own HtmlHelper in ASP.NET MVC 3</a></p>
  
  <p>I've created a class (trimmed it down a bit) as so</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Globalization;
  using System.Linq;
  using System.Linq.Expressions;
  using System.Web;
  using System.Web.Mvc;
  using System.Web.Mvc.Html;
  
  namespace MyWebApp
  {
      public static class ExtensionMethods
      {
           public static MvcHtmlString StateDropDownListFor&lt;TModel, TValue&gt;
                          (this HtmlHelper&lt;TModel&gt; html, 
                                          Expression&lt;Func&lt;TModel, TValue&gt;&gt; expression)
           {
               Dictionary&lt;string, string&gt; stateList = new Dictionary&lt;string, string&gt;()
               {
                  {"AL"," Alabama"},
                  {"AK"," Alaska"},
                  {"AZ"," Arizona"},
                  {"AR"," Arkansas"}
  
                };
                return html.DropDownListFor(expression, 
                         new SelectList(stateList, "key", "value"));
           }
  
       }
  }
  </code></pre>
  
  <p>So far so good,</p>
  
  <p>Inside my controller I also added the reference </p>
  
  <pre><code>using System.Web.Mvc.Html;
  </code></pre>
  
  <p>Now inside my view i have the following</p>
  
  <pre><code>@Html.StateDropDownList(x =&gt; x.State)
  </code></pre>
  
  <p>But I get the following error</p>
  
  <pre><code>System.web.mvc.htmlhelper&lt;system.collections.generic.list&lt;Profile.ProfileImages&gt;&gt; does     not contain a definition for StateDropDownList and no extension method     StateDropDownList acception a first argument of type     system.web.mvc.htmlhelper&lt;System.Collections.Generic.List&lt;Profile.ProfileImages&gt;&gt; could be      found(Are you missing a using directive of an assembly reference?)
  </code></pre>
  
  <p>Could someone please tell me what im doing wrong here.</p>