0

Is it possible to disable the use of display template in specific view?

For example.

I have 3 views index,viewdetails and viewdetails_2 in shared displaytemplates I have a DateTime display template to display formatted datetime and I want to disable the datetime display template in index view.

thanks.

1 Answer 1

1

You have a few options...

First, you can carefully plan your shared templates. For instance, if you only need your templates in your HomeController, you can simply put DisplayTemplates in your ~/Views/Home folder.

Another option is to mark fields you want to use a different template. This can be done with [UIHint()] data attributes, or you can specify template name in the Editor/DisplayFor methods.

A different option would be to use not target your template at a generic type, such as DateTime, and make this a specific DataType. Then you can simply use it wherever you want it, and default to standard behavior otherwise.

If you want to use default processor when you have a generic template defined, there is no way that I know of to say "use the default template". Otherwise, you just don't use EditorFor/DisplayFor, and use TextBoxFor or similar instead.

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.