這是我一直在玩的東西。在HTML頁面中顯示時獲取類的顯示屬性
我有這樣的課;
public partial class DespatchRoster : DespatchRosterCompare, IGuidedNav
{
public string despatchDay { get; set; }
}
我已經爲它添加了元數據。
[MetadataType(typeof(RosterMetadata))]
public partial class DespatchRoster
{
}
public class RosterMetadata
{
[Display(Name="Slappy")]
public string despatchDay { get; set; }
}
在我的HTML我有以下;
<% PropertyInfo[] currentFields = typeof(DespatchRoster).GetProperties(); %>
<% foreach (PropertyInfo propertyInfo in currentFields){ %>
<li class="<%= propertyInfo.Name %>"><%= propertyInfo.Name %></li>
<%} %>
我想看到的是Slappy作爲LI而不是despatchDay。
我知道我以前做過這個,但想不到如何。
沒有得到結果 – griegs