I have the follwing question about MVC 2 with C#.
Here is my Model:
public class Pmjob
{
[Tooltext="Hier soll der Name eingegeben werden"]
[DisplayName("Type")]
public int Name { get; set; }
}
Now I want to reach the Tooltext item in my view, e. g.:
@Html.ToolTextFor(Model => Model.Pmjob.Name)
or in the BL:
if ( Model.Pmjob.Name.Tooltext == "") {
}
Is this possible?
Create an abstract class MetaDataAttribute :
Make your attribute inherit from MetaDataAttribute :
Create the custom MetaDataProvider :
And replace the default one (global.asax.cs) :
Finally, you can access it in your view (or in a Html Helper ) :
Source :