开发者

Problem creating extension method for HTMLHelper ('TextBoxFor' is not a member of 'System.Web.Mvc.HtmlHelper(Of TModel)')

I have the following extension method that I've built and have working for one MVC3 project, but when trying to use it in another, the compiler (not the view) gives me the error;

Error   1   'TextBoxFor' is not a member of 'System.Web.Mvc.HtmlHelper(Of TModel)'...

Intellisense shows none of these html element shorcut methods.

I'm sure it's just because I'm missing a reference or something, but beats me what it is.

FImports System.Runtime.CompilerServices

Public Module HtmlHelperExtension

<Extension()> _
Public Function WatermarkedTextBoxFor(Of TModel, TProperty)(ByVal htmlHelper As System.Web.Mvc.HtmlHelper(Of TModel), ByVal expression开发者_StackOverflow中文版 As Linq.Expressions.Expression(Of Func(Of TModel, TProperty)), ByVal htmlAttributes As IDictionary(Of String, Object)) As MvcHtmlString

    Dim propertyMetaData = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData)

    Return htmlHelper.TextBoxFor(expression, New RouteValueDictionary(htmlAttributes) From {
                                 {"class", "jq_watermark"},
                                 {"title", If(Not String.IsNullOrEmpty(propertyMetaData.Watermark), propertyMetaData.Watermark, propertyMetaData.GetDisplayName())}
                             })

End Function
End Module


I needed to import the System.Web.Mvc.Html namespace

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜