Passing Enum to ASCX via html markup
I've this ASCX:
public partial class TopPhoto : User开发者_如何学CControl
{
public TopPhotoEnum Mode { get; set; }
public int PhotoNumber { get; set; }
...
I want to set those property via html markup like this:
<uc1:TopPhoto ID="TopPhoto1" runat="server" Mode="TopPhotoEnum.Today" PhotoNumber="5" />
update
public enum TopPhotoEnum
{
Today,Week,Month,Year,AllTime
}
but this returns me an error like this:
Impossible to create object of type 'UpVoteEntities.TopPhotoEnum' from string 'TopPhotoEnum.AllTime' property 'Mode'.
Is there a standard way to achieve this?
You could try:
<uc1:TopPhoto ID="TopPhoto1" runat="server" Mode="Today" PhotoNumber="5" />
But it depends on how and where your enum is defined.
精彩评论