开发者

Can I have multiple display templates for an object in ASP.NEt MVC 3?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜