asp.net, razor codes

Posted on 2013-10-05
Medium Priority
Last Modified: 2013-10-07
@Html.LabelFor(m => m.email, new { @class="control-label" })
Just try to make above codes working in MVC 3 razor but now alert an error.

Compiler Error Message: CS1928: 'System.Web.Mvc.HtmlHelper<SuretyNetwork.Controllers.SignUpModel>' does not contain a definition for 'LabelFor' and the best extension method overload 'System.Web.Mvc.Html.LabelExtensions.LabelFor<TModel,TValue>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TValue>>, string)' has some invalid arguments
Question by:solution1368
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 39550315

You cannot define a class in a LabelFor helper. You may check the constructor of LabelFor here.

What you can do is not use the helper, and instead use plain Razor as:

<label for="@Model.email" class = "control-label">

Open in new window

An other way would be defining your own helper. Some suggestions are here.

LVL 16

Accepted Solution

Stephan earned 2000 total points
ID: 39550459

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
There is a wide range of advantages associated with the use of ASP.NET. This is why this programming framework is used to create excellent enterprise-class websites, technologies, and web applications.
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Watch the video of Kernel Migrator for SharePoint, which demonstrate the process easily of migration from SharePoint to SharePoint, OneDrive for Business & Google Drive servers, Public Folder to SharePoint, File Server to SharePoint. The tool has va…

621 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