Solved

MVC Label CSS question

Posted on 2013-01-31
2
516 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 100 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

738 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