开发者

Passing Enum to ASCX via html markup

开发者 https://www.devze.com 2023-03-20 18:15 出处:网络
I\'ve this ASCX: public partial class TopPhoto : User开发者_如何学CControl { public TopPhotoEnum Mode { get; set; }

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

精彩评论

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