MVC :: How To Use The EditorTemplate

Jan 12, 2011

I read that EditorTemplates are loaded automatically, but from asp.net mvc 2 and now 3 with razor, I still cant get this to work.

My model looks like this:

[Code]....

My view looks like this:

~/Views/Roles/Edit.cshtml

[Code]....

~/Views/Roles/EditorTemplates/RoleViewModel.cshtml

[Code]....

If i move the content from the

[Code]....

to the actual page, then it works, it shows the checkbox, etc. But with this current setup, all that shows up is the count of the number of roles.

What am I doing wrong?

View 3 Replies


Similar Messages:

MVC :: DisplayTemplate And EditorTemplate Naming?

Feb 23, 2010

I've got a couple of questions about the naming convention for the DisplayTemplates and EditorTemplates in MVC 2.

If for example I have a customer object with a child list of account how do I:

Create a display template for the list of accounts, what is the file called?When I'm doing a foreach( var c in Model.Accounts ) how do I call a display temple while in the foreach? When I do Html.DisplayFor( x => x ) x is the model and not in this case "c".

View 1 Replies

Using MVC2 EditorTemplate For DropDownList?

Apr 29, 2010

I've spent the majority of the past week knee deep in the new templating functionality baked into MVC2. I had a hard time trying to get a DropDownList template working. The biggest problem I've been working to solve is how to get the source data for the drop down list to the template. I saw a lot of examples where you can put the source data in the ViewData dictionary (ViewData["DropDownSourceValuesKey"]) then retrieve them in the template itself (var sourceValues = ViewData["DropDownSourceValuesKey"];) This works, but I did not like having a silly string as the lynch pin for making this work.

[code]...

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved