?
Solved

How to keep the Razor files free of code logic?

Posted on 2011-10-20
2
Medium Priority
?
248 Views
Last Modified: 2012-05-12
I am trying to understand how to apply best practices coding to my Razor files.  I understand that I should keep the Razor files free of code logic, when possible. But often calling C# properties is important to setting the CSS. So do these make sense to accomplish this?

- Move the HTML definition to the Model, or a Helper class.
- Make Model return a property that's the CSS class?

If not, how best can I accomplish the goal of keeping the Razor files free of code logic?

Thanks!
0
Comment
Question by:newbieweb
2 Comments
 
LVL 9

Accepted Solution

by:
gery128 earned 2000 total points
ID: 37004773
Ideally, model should not contain/represent the view/html information.

You should consider writing Helper class that will populate the css/html for you and inject/use it in view.

That would be better approach, and for MVC best practices, I would recommend this link:

asp-net-mvc-best-practices
0
 

Author Closing Comment

by:newbieweb
ID: 37009932
Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question