c#-通过html标记将枚举传递到ASCX
作者:互联网
我有这个ASCX:
public partial class TopPhoto : UserControl
{
public TopPhotoEnum Mode { get; set; }
public int PhotoNumber { get; set; }
...
我想通过html标记设置这些属性,如下所示:
<uc1:TopPhoto ID="TopPhoto1" runat="server" Mode="TopPhotoEnum.Today" PhotoNumber="5" />
更新
public enum TopPhotoEnum
{
Today,Week,Month,Year,AllTime
}
但这会给我这样的错误:
Impossible to create object of type 'UpVoteEntities.TopPhotoEnum' from string 'TopPhotoEnum.AllTime' property 'Mode'.
是否有实现此目的的标准方法?
解决方法:
您可以尝试:
<uc1:TopPhoto ID="TopPhoto1" runat="server" Mode="Today" PhotoNumber="5" />
但这取决于枚举的定义方式和位置.
标签:ascx,asp-net,c 来源: https://codeday.me/bug/20191208/2089442.html