I've defined an extension method called BootstrapDropDownFor
which has a definition of
public static IHtmlString BootstrapDropDownFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, dynamic options, string defaultOption)
When trying to use it in a .cshtml
file
@Html.BootstrapDropDownFor(m => m.RequestType, ViewBag.RequestTypes, "-- Select --")
I get the following error:
'HtmlHelper<WebPermissionModel>' does not contain a definition for 'BootstrapDropDownFor' and the best extension method overload 'HtmlHelpers.BootstrapDropDownFor<TModel, TValue>(HtmlHelper<TModel>, Expression<Func<TModel, TValue>>, dynamic, string, string)' requires a receiver of type 'HtmlHelper<TModel>'
However, by adding a cast to the options
parameter, as below, I can get rid of the error.
@Html.BootstrapDropDownFor(m => m.RequestType, (object) ViewBag.RequestTypes, "-- Select --")
How come adding a cast fixes this issue?