I was wondering how much code is acceptable in a view ? It is acceptable to use foreach or if such if a list of items is empty.. show some message ? or should this be done in the controller ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
in a really few works
The View should containt all the code you need for your presentation logic even
ForEach(if you need them)Some people like to create HTML helper to split down the presentation logic and inclapsulate it into an adhoc method
The control should be very skinny: it should just get the user interaction and delegate them to the right component. It may contain some validation logic (user input etc) but it really depends by your business requirements