On a specific View, I pass in a new model to a partial view via:
@Html.Partial("view.cshtml", new Model1())
Then on the partial I need to access all of its properties, and attributes, including a new custom attribute I made.
My new attribute uses MetadataAware:
public class ReportDescriptionAttribute : Attribute, IMetadataAware
{
public ReportDescriptionAttribute(string resourceKey)
{
this.ReportDescription = resourceKey;
}
public string ReportDescription { get; set; }
public void OnMetadataCreated(ModelMetadata metadata)
{
metadata.AdditionalValues["ReportDescription"] = this.ReportDescription;
}
}
so on my model I can now use [ReportDescription("resourcekey")]
But in my partial view, when I use @foreach (var property in ViewData.ModelMetadata.Properties)
it does not show up.
*I also created the HTML helper class, as stated in this very similar question, but cannot get it to work.
Thoughts? Thanks for your help
Above, Stephen was able to point me in the right direction. My additional attribute was there the whole time, and I didn't even need the helper class, just the IMetaDataAware.