0

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 IEnumerable 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)?

1 Answer 1

1

You are looking for EditorTemplate

You could also specify the templateName in the DisplayFor methods.

Sign up to request clarification or add additional context in comments.

Comments

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.