0

I tried using this example here like this

<%: Html.TextBoxFor(model => model.MyList[0].FirstName, model.MyList[0].IsEnabled ? (object)new { disabled = "disabled" } : new { })%>

but that gave me an error

"The name model doesn't exist in the current context"

Is there a way to do this in vanilla asp.net MVC 3 without using an if else condition?

Thanks for your time...

Community
  • 1
  • 1
user20358
  • 13,484
  • 31
  • 108
  • 179

2 Answers2

1

I fixed this: I should use the actual model I am passing in to the view. Notice the change in Caps on the second parameter.

<%: Html.TextBoxFor(model => model.MyList[0].FirstName, Model.MyList[0].IsEnabled ? (object)new { disabled = "disabled" } : new { })%>
user20358
  • 13,484
  • 31
  • 108
  • 179
0

Just quickly checking for this error message suggests that maybe your web.config is broken.

The name 'model' does not exist in current context in MVC3

Community
  • 1
  • 1
James Osborn
  • 1,255
  • 6
  • 11