from linkitem collection to dropdownlist



How would be the "episerver way" to render a linkitemcollection as a dropdownlist???. I know I can do it with normal techniques MVC .NET, but I wonder if with EpiServer 8 I can code it easily.


Sep 16, 2015 16:00


I think that you could prepare custom renderer for LinkItemCollection, that will render a dropdownlist.

Then in your model use the statement below to display property:

@Html.PropertyFor(x => x.Links)

Here is a good article about rendering properties:

How to customize rendering of properties

and also the documentation:

rendering properties

Sep 16, 2015 22:22

Thank you  Grzegorz, I'll rendered the linkitemcollection (to select homepage for country/language) that way, in Views/DisplayTemplates/LinkItemCollection.cshtml:

<select id="selectlanguages">
       <option value="#">Select Country and Language</option>
       @foreach (var linkItem in Model ?? Enumerable.Empty<LinkItem>())
           string linkUrl;
           PermanentLinkMapStore.TryToMapped(linkItem.Href, out linkUrl);
           <option value=@linkUrl>@Html.ContentLink(linkItem)</option>

<script type="text/javascript">
    $(function () {
        $("#selectlanguages").on("change", function () {
            window.location.href = $(this).val();

It's working fine.
Sep 22, 2015 13:13
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.