I have just seen a video about ASP.NET MVC and the developer in that video was kind of mixing the HTML with C# or MVC markup. So, how can I hear people talking about sepration in MVC and I saw a mix! Could any anyone clarify for me this point?
|
The mix is supposed to be minimal. You should write code only for getting values out of variables passed to the view, or calling functions that would "render" form elements, etc. I suppose you could add non-trivial code in there, but you should move all the complex processing to the controller. |
|||
|
MVC Still renders as HTML. If you want to create a robust custom control dynamically at runtime then there will be some logic around that creation. But the data layer should be seperate from the view. |
|||
|
The view (.cshtml and .aspx) files are OK if they contain code. However, that code should be specific to data display and not to data processing. The view should only know how to display the expected viewmodel/model that it is given and should not do calculations, persistence, or anything else that is not directly related to "prettifying" the data for the viewing pleasure of the user. The closest thing to business logic that you should have in the view is client side validation code that may be necessary to reduce server trips. |
|||
|