ADDING Labels in MVC2
How on earth do you add labels in MVC2? Intellisence says that there is an overload for label that takes 2 strings. I am getting an error telling me there is no such overload. And there doesn't appear to be any documentation anywhere telling how to do it? How do you do it in mvc2?
Update: Added an example of how I am trying to add a lab开发者_如何学Pythonel
%><%=Html.Label(labelId, labelText)%><%
I was just reading that I may have to write an extension method of some sort. Do you know how to do that?
you have following options: Static label to render text
<%= Html.Label("string to be displayed") %>
Label for model
<%= Html.LabelFor(model=>model.YourObject) %>
Where entity (class that represents the model is defined
public class Foo{
[DisplayName("Team")]
public string YourObject{get;set;}
}
this was basic usage
documentation is here for all of Html.Label labelfor and labelformodel http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28SYSTEM.WEB.MVC.HTML.LABELEXTENSIONS.LABEL%29&rd=true
Update:
definition for Html.Label("string"):
MvcHtmlString AdministratorMenuLink(this HtmlHelper helper, string text){}
Where this HtmlHelper is internal which you never use unless you test. It is intergrated because it is extending this function.
In this case you ignore it and follow up only with the text.
精彩评论