Html.LabelFor

A

AMP

Why does this return "Success" and not the bool that it represents:

This Returned <%= Html.LabelFor(m=>m.Success)%>

My Property:
private bool success = false;
public bool Success
{
get { return success; }
set { success = value; }
}

I dont even get a casting error

Thanks
 
P

Patrice

Hi,

LabelFor is to define the label for another form field. So it makes sense to
return the property name (or the DisplayName attribute if you want something
else) rather than the property value. You may want to use Html.Label instead
(not familiar with MVC but I suppose it exists).

As a side note creating members differing only in casing is generally
considered as a bad practice (error prone and if a library can impair its
usage from non case sensitive languages)...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top