到底如何在 MVC2 中添加标签? Intellisence 表示,标签有一个重载,需要 2 个字符串。我收到一条错误消息,告诉我没有这样的过载。而且似乎没有任何文档告诉您如何做到这一点?在mvc2中怎么做呢?
更新:添加了我如何尝试添加标签的示例
%><%=Html.Label(labelId, labelText)%><%
我刚刚读到我可能必须编写某种扩展方法。你知道该怎么做吗?
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 label
%><%=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?
发布评论
评论(1)
您有以下选择:
用于渲染文本的静态标签
模型的标签
其中定义了实体(表示模型的类,
这是基本使用
文档,适用于所有 Html.Label labelfor 和 labelformodel
http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28SYSTEM.WEB.MVC.HTML.LABELEXTENSIONS.LABEL%29& rd=true
更新:
此 HtmlHelper 是内部的,除非您进行测试,否则您永远不会使用它。
它被集成是因为它扩展了这个功能。
在这种情况下,您可以忽略它并仅跟进文本。
you have following options:
Static label to render text
Label for model
Where entity (class that represents the model is defined
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:
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.