title: Extending HtmlHelper for Kendo DropDownList
body: <p>I have written a htmlhelper extension method for text boxes and dropdown list in mvc and c# projects and currently I am using the Kendo UI and have used the controls provided by Kendo for Dropdownlist and Textbox.</p>
  
  <p>I have tried using the same approach as in MVC </p>
  
  <pre><code>    public static MvcHtmlString Custom_DropDownList(this  HtmlHelper helper, string name, IEnumerable&lt;SelectListItem&gt; list)
      {
          return Custom_DropDownList(helper, name, list);
      }
  </code></pre>
  
  <p>but I can't expose the above helper method with kendo dropdown. I know, this is wrong and I have been struggling with that.</p>
  
  <p>I am populating the dropdown values from database and in addition to the current values in the list, 
  I would like to </p>
  
  <ul>
  <li><p>append one blank row at the top of list </p></li>
  <li><p>or (ALL) option at the top of the list (when there are more than one values), </p></li>
  <li><p>(ALL) will not be displayed if the dropdown has only one value.</p></li>
  </ul>
  
  <p>In case anyone has implemented the dropdown helper methods in kendo, is requested to share the idea or suggest me a way to get around this.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>using custom htmlhelper for normal dropdownlist, we do like this</p>
  
  <pre><code>public static MvcHtmlString StateDropDownList(this HtmlHelper html)
  {
      return html.TextBox("foo");
  }
  </code></pre>
  
  <p>and then we can use this htmlhelper in the code.</p>
  
  <p>How to achieve the same code for Kendo().DropDownList() as I haven't seen any example doing so, neither, I don't knpw, how Kendo dropdownlist parses the html internally. I tried to do something like below, but I unable to find the solution</p>
  
  <pre><code>public static MvcHtmlString Custom_DropdownList(this HtmlHelper helper, string name, IEnumerable&lt;SelectListItem&gt; list, string option, object htmlAttributes)
  {
        var divTag = new TagBuilder("div");
        divTag.AddCssClass("k-list-container k-popup k-group k-reset");
        divTag.Attributes.Add("id", "ddlMemType-list");
        divTag.Attributes.Add("data-role", "popup");
        divTag.Attributes.Add("style", "position: absolute; height: auto; display: none;");
  
        TagBuilder ulTag = new TagBuilder("ul");
  
        ulTag.Attributes.Add("id", "ddlMemType_listbox");
        ulTag.MergeAttribute("unselectable", "on");
        ulTag.AddCssClass("k-list k-reset");
        ulTag.MergeAttribute("tabindex", "-1");
        ulTag.MergeAttribute("role", "listbox");
        ulTag.MergeAttribute("aria-hidden", "false");
        ulTag.MergeAttribute("aria-live", "off");
        ulTag.MergeAttribute("style","overflow: auto;");
        ulTag.InnerHtml += Environment.NewLine;
  
        foreach (var item in list)
        {
              var liTag = new TagBuilder("li");
              liTag.MergeAttribute("tabindex", "-1");
              liTag.MergeAttribute("role", "option");
              liTag.MergeAttribute("unselectable", "on");
              liTag.AddCssClass("k-item k-state-selected k-state-focused");
              liTag.Attributes.Add("id", "ddlMemType_option_selected");
              liTag.MergeAttribute("aria-selected", "true");
  
              ulTag.InnerHtml += string.Format("  {0}{1}{2}", liTag.ToString(), item.Text, Environment.NewLine);
         }
         divTag.InnerHtml += string.Format("{0}{1}", ulTag.ToString(), Environment.NewLine);
         return MvcHtmlString.Create(divTag.ToString(TagRenderMode.Normal));
      }
  </code></pre>