Error HtmlHelper<dynamic> in mvc 5 RRS feed

  • Question

  • User-1579955087 posted

    Error: 'HtmlHelper<dynamic>' has no applicable method named 'Hidden' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax

    Code in View

    @Html.Hidden("cityId", ViewBag.Citys.ToString(), new { @id = "cityId" })
    Wednesday, November 7, 2018 12:04 PM

All replies

  • User-1646292712 posted

    You change

    @Html.Hidden("cityId", (string)ViewBag.Citys.ToString(), new { @id = "cityId" })
    Wednesday, November 7, 2018 12:29 PM
  • User753101303 posted


    And if using @model dynamic you really can't use something strongly typed ?

    Wednesday, November 7, 2018 12:30 PM