Saturday, March 24, 2012

web custom control designtime problem

Hello,
I would like to make my own dropdownlist and add a collection as a generic
List.
When I enter items @dotnet.itags.org. designtime, @dotnet.itags.org. runtime they are gone.
Can anyone tell me please what the problem is?
This is my code:
[ToolboxBitmap(typeof(DropDownList))]
[ToolboxData("<{0}:MaxDropDownList runat=server></{0}:MaxDropDownList>")]
public class MaxDropDownList : System.Web.UI.WebControls.DropDownList,
IMaxControl
{
private List<GroupRights> _GroupRights = new List<GroupRights>();
[Category("Rights")]
[Editor("System.Web.UI.Design.WebControls.ListItemsCollectionEditor,System.D
esign,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
typeof(UITypeEditor))]
public List<GroupRights> Rights
{
get
{
return _GroupRights;
}
set
{
_GroupRights = value;
ViewState["Rights"] = Rights;
}
}
}
Thanx in advance,
Rotsjyou never read the values back from the viewstate.
-- bruce (sqlwork.com)
rotsj wrote:
> Hello,
> I would like to make my own dropdownlist and add a collection as a generic
> List.
> When I enter items @. designtime, @. runtime they are gone.
> Can anyone tell me please what the problem is?
> This is my code:
> [ToolboxBitmap(typeof(DropDownList))]
> [ToolboxData("<{0}:MaxDropDownList runat=server></{0}:MaxDropDownList>")]
> public class MaxDropDownList : System.Web.UI.WebControls.DropDownList,
> IMaxControl
> {
> private List<GroupRights> _GroupRights = new List<GroupRights>();
> [Category("Rights")]
> [Editor("System.Web.UI.Design.WebControls.ListItemsCollectionEditor,System
.Design,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
> typeof(UITypeEditor))]
> public List<GroupRights> Rights
> {
> get
> {
> return _GroupRights;
> }
> set
> {
> _GroupRights = value;
> ViewState["Rights"] = Rights;
> }
> }
> }
> Thanx in advance,
> Rotsj
>
thank you for your reply.
when I change the "rights" property like below it still doesn't work:
(In the Get method i first read the viewstate)
public List<GroupRights> Rights
{
get
{
_GroupRights = (List<GroupRights> )ViewState["Rights"];
return _GroupRights;
}
set
{
_GroupRights = value;
ViewState["Rights"] = Rights;
}
}
The control does not remember anything. Even in designtime it will not
remember his items.
Thanx in advance,
Rotsj
"bruce barker" <nospam@.nospam.com> schreef in bericht
news:O2$IhfPNHHA.5104@.TK2MSFTNGP06.phx.gbl...
> you never read the values back from the viewstate.
> -- bruce (sqlwork.com)
> rotsj wrote:

0 comments:

Post a Comment