I have a form in the MVC view that contains several text fields, drop-down lists and text areas. I use the HTML helper to create these controls, including pre-populating them with View Data if necessary and applying styles through the htmlAttributes parameter.
This works great with TextBox and DropDownLists controls, etc. However, when I add htmlAttributes to TextArea, it stops working, claiming that the best overloaded method has some invalid arguments, the code that crashes:
Html.TextArea("Description", ViewData["Description_Current"], new { @class = "DataEntryStd_TextArea" })
Resulting error:
'System.Web.Mvc.HtmlHelper' does not contain a definition for 'TextArea' and the best overload of the extension method 'System.Web.Mvc.Html.TextAreaExtensions.TextArea (System.Web.Mvc.HtmlHelper, string, string, object)' has some invalid arguments
For comparison, TextBox calls that work fine:
Html.TextBox("TelephoneNumberAlternate", ViewData["TelephoneNumberAlternate"], new { @class = "DataEntryStd_TextBox" })
I tried to explicitly reference TextAreaExtensions.TextArea and include the HtmlHelper argument, but that didn't matter.
For reference, calling TextArea works fine without the htmlAttributes parameter. In addition, I tried to specify a name / value dictionary for the class attribute, however this has the same problem.
Any ideas what I'm doing wrong?