Ask a Question related to ASP.NET, Design and Development.
-
Class #1
Collection Property in web custom control
Hi all,
I'm building a custom control. I would like that on the control you can set
some 'rights'
For that I have an enum:
public enum GroupRights
{
Group0 = 0,
Group1 = 1,
Group2 = 2,
Group3 = 3,
Group4 = 4,
Group5 = 5,
}
In design time I want to set these right (can be multiple rights at the same
time)
So I put them in a generic list:
[Category("Rights")]
[DefaultValue("")]
[Localizable(true)]
[Bindable(true)]
public List<GroupRights> ControlRights
{
get
{
List<GroupRights> temp = (List<GroupRights>)ViewState["ControlRights"];
return ((object)temp == null) ? new List<GroupRights>() : temp;
}
set
{
ViewState["ControlRights"] = value;
}}
In desgin time I get the controls window with the GrouRights enum to choose
from.
But when I add one right in the collection window I get the message:
Cannot create an object of type
'System.Collections.Generic.List`1[[GroupRights, MaxControls,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' from its string
representation '(Collection)' for the 'ControlRights' property.
Also the property can not be read out during runtime.
What am I doing wrong or forgetting?
tia,
Class
Class Guest
-
Custom Control - Collection Property
Hey gang. I am taking the task of trying to learn how to write custom web controls. I have started with inheriting from the VS 2005 default which... -
Nested Collection property in a custom control
I have the extactly the same problem.. I am creating a control where a collection property is exposed which has a nested collection object. It... -
Collection Property of Another Custom Server Control
Hi, I read more and figured out how to build what I needed: <cc> <item></item> <item></item> </cc> when <item> is an editable control in... -
Help with using a custom collection as a property for a TextBox derrived control.
Hi I am creating a new TextBox control but I am having problems when I am trying to add my own collection to the control and persisting the... -
Custom Control nad Collection property
I have a collection-property on my control. I Add the items through a collection editor, and items tags appears. <bugge:Control>... -
Michael Tkachev #2
Re: Collection Property in web custom control
Your class must be serializible. Or use Session instead of ViewState.
Sincerely yours,
Michael B. Tkachev.
[email]m_tkachev@hotmail.com[/email]
"Class" <NoSpam@Class> wrote in message
news:eOfpVChOHHA.2140@TK2MSFTNGP03.phx.gbl...> Hi all,
>
> I'm building a custom control. I would like that on the control you can
> set some 'rights'
> For that I have an enum:
> public enum GroupRights
>
> {
> Group0 = 0,
> Group1 = 1,
> Group2 = 2,
> Group3 = 3,
> Group4 = 4,
> Group5 = 5,
> }
>
> In design time I want to set these right (can be multiple rights at the
> same time)
> So I put them in a generic list:
>
> [Category("Rights")]
> [DefaultValue("")]
> [Localizable(true)]
> [Bindable(true)]
> public List<GroupRights> ControlRights
> {
> get
> {
> List<GroupRights> temp = (List<GroupRights>)ViewState["ControlRights"];
> return ((object)temp == null) ? new List<GroupRights>() : temp;
> }
>
> set
> {
> ViewState["ControlRights"] = value;
> }}
>
> In desgin time I get the controls window with the GrouRights enum to
> choose from.
> But when I add one right in the collection window I get the message:
>
> Cannot create an object of type
> 'System.Collections.Generic.List`1[[GroupRights, MaxControls,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' from its string
> representation '(Collection)' for the 'ControlRights' property.
>
> Also the property can not be read out during runtime.
>
> What am I doing wrong or forgetting?
>
> tia,
>
> Class
>
>
>
Michael Tkachev Guest



Reply With Quote

