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 Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

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