I’m finally starting to learn MVC 3 with Razor. I’ve a problem with checking which model i’m passing along.
I need to convert this 3 kind of MVC 2 example code to Razor/MVC 3:
<li class="<%= Model is FooModel ? "active" : null %>"><a href="<%= Url.Action("Foo") %>Foo</a></li>
<li class="<%= Model is DooModel || Model is BooModel ? "selected" : null %>"><a href="<%= Url.Action("Doo") %>">Doo</a></li>
<% if (Model is FooModel){ %>Foo<% } else if(Model is DooModel){ %>Doo<% } %>
<% if (Model is FooModel)
Html.RenderPartial("Foo");
else if(Model is DooModel)
Html.RenderPartial("Doo"); %>
Thanks for any kind of help.
Something like this should work:
Notes: (1) You shouldn’t return
null, just don’t return anything. (2) I’m not sure what you want inside your first and second block whatFooandDooare and what you need to do with them.