Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Preetee Gangoosirdar 56 posts 257 karma points
    Jun 17, 2019 @ 12:12
    Preetee Gangoosirdar
    0

    Dictionary item does not work in FieldType.DropDownList.cshtml

    Hi there am trying to use the dictionary item as default value in first option value in FieldType.DropDownList.cshtml

         <select id="@Model.Id" ng-options="item.name for item in Lists track by item.id" class="@ViewData[" Alias"].ToString()" ng-model="List">       
    <option value="">@Html.GetDictionaryItem("test")<option>
         </select>
    

    It throw the following exception

    HttpCompileException:  Views\Partials\Forms\dae343e5-c611-4411-b941-22d883fe76ac\FieldType.DropDownList.cshtml(6): error CS1928: 'System.Web.Mvc.HtmlHelper<Umbraco.Forms.Mvc.Models.FieldViewModel>' does not contain a definition for 'GetDictionaryItem' and the best extension method overload 
    

    i have the following namespace @model Umbraco.Forms.Mvc.Models.FieldViewModel

    Thank you for help

  • Preetee Gangoosirdar 56 posts 257 karma points
    Jun 17, 2019 @ 17:17
    Preetee Gangoosirdar
    0

    Hi i have managed to sorted to it out , may be this might someone else if ever they come across same issue

    In my form.cshtml

         if (fieldAlias == "List")
     {
    var dicAlias = Html.GetDictionaryItem("SelectArchivedropdown");
    @Html.Partial(FieldViewResolver.GetFieldView(Model.FormId.ToString(), f.FieldTypeName, f.Caption), f, new ViewDataDictionary { { "Alias", "List" }, { "dicAlias", @dicAlias } })
    }
    

    In my FieldType.DropDownList.cshtml

    <select id="@Model.Id" ng-options="item.name for item in Lists track by item.id" class="@ViewData[" Alias"].ToString()" ng-model="List">       
    <option value="">@Html.Raw(ViewData["dicAlias"].ToString())</option>
    </select>
    
Please Sign in or register to post replies

Write your reply to:

Draft