?
Solved

MVC Label CSS question

Posted on 2013-01-31
2
Medium Priority
?
529 Views
Last Modified: 2013-01-31
Hello all,

What is the best way to handle dealing with css properties within MVC.  For example, I have a design template that has labels etc. that have a class defined such as this:

<label for="testlabel" class="control-label">Customer ID</label>

<input type="text" id="testtb"></input>

So the input I think I can just use a EditorFor or TextBoxFor.   What should I do with the labels?  Not sure if just leave it as they are or if true MVC I should be using something different.

Thanks
0
Comment
Question by:sbornstein2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 400 total points
ID: 38841438
The EditorFor, TextBoxFor, and any other *For methods are just helper methods. Don't get too caught up in thinking that they are the embodiment of MVC. MVC is the architectural style regarding how your app is put together (the mdoels, views, and controllers). The helpers just make placing the HTML controls that would associated with various parts of your model a bit easier.

You can create a new anonymous object that has the attributes you would like to add to the label.

e.g.

@Html.LabelFor(modelItem => modelItem.Message, "Customer ID", new { @class = "control-label" })

Open in new window


...this is the new { @class = "control-label" } part in the above example. In this particular case, the "@" on "@class" is required since the keyword "class" is a reserved word in C#.
0
 

Author Closing Comment

by:sbornstein2
ID: 38841443
thanks again Kaufmed.  Huge help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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!
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

762 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