开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜