Is it possible to have multiple display templates for the same object in asp.net mvc?
In my situation I have a Comment
object. I would like to use DisplayFor to automatically loop throught an IEnumerabl开发者_开发知识库e in my view and display the proper template for each item. This works great. Now say I have another view where I also need to display a list of comments in the same manner...But I wants these comments to be editable by the user.
So basically, Can I have 2 display templates, one for read-only display and one for editable display(or other similar scenarios)?
You are looking for EditorTemplate
You could also specify the templateName in the DisplayFor methods.
精彩评论