I know that I have seen this before. I can't remember if it was a C4MVC template demo or an input builder thing! I need to know how I can use the convention of CamelCasing my view model properties and having the "CamelCasedProperty" rendered in the label as "Camel Cased Property". This should be handled by the create new view wizard rather than programatically handling this.
The label is specified by using the Label Attribute applied to the property.
In ASP.NET MVC, a section is a piece of code that we want to render in a layout page. This allows us to render a specific view content in any location of a layout. In order to declare a section in a view, we use the @section keyword followed by the name of the section. @section name { }
I don't think what you want is possible in vanilla ASP.NET MVC 2.
In ASP.NET MVC 2 you need to decorate your model with a DisplayName attribute with the text you want and then the auto generated wizard will use LabelFor
to output the label for the property. Eg:
class MyModel()
{
[DisplayName("Your Property Name")]
public string YourPropertyName { get; set; }
}
Then in the view:
<%= Html.LabelFor(m => m.YourPropertyName) %>
If you saw a demo of it being done some other way it could have been from the MvcContrib project for InputBuilders.
Here is direct link to the part of the project I think your referring to:
http://www.lostechies.com/blogs/hex/archive/2009/06/09/opinionated-input-builders-for-asp-net-mvc-part-2-html-layout-for-the-label.aspx
The text highlighted in red are labels that come from the Model type. The label is created from the PropertyInfo object that represents the respective properties of the mode.
The label is Property Name.
The label is the Property Name that is split on the pascal case property name.
The label is specified by using the Label Attribute applied to the property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With