Question

In my .cshtml file, I'm getting an error wherever I use @Html.TextBoxFor

here's a sample code:

@model WebComposite.Models.CompositeModel

<label for="name">Name</label>
@Html.TextBoxFor(m => m.name)

Error:

Error #1:
'System.Web.Mvc.Html.InputExtensions.TextBoxFor<TModel,TProperty>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TProperty>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Error #2: 
One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?

any ideas?

Was it helpful?

Solution

in case anyone else is wondering, here's how I resolved it:

1. right click on the project -> select properties
2. select Application
3. change "target framework" (I was at 4.5, so I changed it to 4)
4. change "target framework" to whatever it was before step 3

web.config is cleaned up, appropriate references are added, do a build and everything should be back to normal

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top