How do I call this function?
public static HtmlString DropdownForEnum<TModel>(this HtmlHelper<TModel> helper, Type type,
string name, string optionLabel, object htmlAttributes)
Inside a page (using the razor syntax):
@Html.DropDownForEnum(typeof(enumToDropDown), name: "Foo", optionLable: "Bar", htmlAttributes: null)
The "this" part of the arguments indicates to me that that's an "extension method" - basically a helper method that does some public operations on an object, but can be called as though it's a method of that object.
HtmlHelper<Model> helper;
Type type;
String name;
String optionLabel;
Object htmlAttributes;
helper.DropdownForEnum(type, name, optionLabel, htmlAttributes);
// or, the standard way for calling a static:
NameOfClassWhereYouFoundMethod.DropdownForEnum(helper, type, name, optionLabel, htmlAttributes);
This is an extension method on HtmlHelper. As so, it should be called like this:
HtmlHelper<TModel> instance = new HtmlHelper<TModel>();
instance.DropdownForEnum(type, name, optionLabel, htmlAttributes)
where TModel is the type assigned to the generic at the moment of declaration.
Please see also this question: MVC3 Razor DropDownListFor Enums
About Extension Methods, please see this: http://msdn.microsoft.com/en-us/library/vstudio/bb383977.aspx