A
A
Alexander2015-03-19 16:34:37
ASP.NET
Alexander, 2015-03-19 16:34:37

Should a View contain logic?

What should be in View besides markup?
For example

@if(Model.Gender != null)
{
//тут что-то отображаем, если поле не пусто
}

Or this piece should be taken out in partial or still where?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
asdz, 2015-03-19
@asdz

If it’s elementary logic, I think it’s better to do it in a view than to produce the same views that differ in several details, but sometimes transferring logic to helper methods (css class selection logic, text names) allows you to make your code more testable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question