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...

2 Answers 2

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 { })%>
Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

Fair enough. My second guess would be the model/Model capitalisation, that's caught be out more than once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.