Solved

MVC Label CSS question

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

740 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