Umbraco Razor, Fill in a Dropdownlist or Mega drop down from DataTypes using a Function

@using Examine
@using Examine.SearchCriteria
@using UmbracoExamine
@using System.Xml.XPath


@helper fillDropDown(int thisPreValue, string thisLocation)
   
{XPathNodeIterator preValueRootElementIterator = umbraco.library.GetPreValues(thisPreValue);
  preValueRootElementIterator.MoveNext();
  XPathNodeIterator preValueIterator = preValueRootElementIterator.Current.SelectChildren("preValue", "");
 
<div class="col_4 responsive_thirds">
        <ul>

  @Html.Raw("<li><strong><a href=\"#selectionmenu?location=" + @thisLocation + "\">" + @thisLocation + "</strong></li>")
  @while (preValueIterator.MoveNext())
{

  <li>
   @Html.Raw("<a href=\"#selectionmenu?location=" + @preValueIterator.Current.Value + "\">")
  @preValueIterator.Current.Value
@Html.Raw("</a>")
 </li>

}
</ul>
</div>
}



          @fillDropDown(1083,"Scotland")
   @fillDropDown(1084,"East Midlands")


 

Comments

Popular posts from this blog

Umbraco - Reset the Admin Password via SQL Server

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco

Umbraco Macro for IFrame when Embedding Video, Vimeo Universal Player, or other types of IFrame on to a Page XSLT version and Razor Version