Child Controls inserted in Code Behind

K

kruiz

Hi, hope somebody could help me! ... I'm building a Toolbar Web Custom
Control. So i created 3 classes,

[ PersistChildren(false),
ParseChildren(false, "Buttons"),
ControlBuilder(typeof(ToolbarControlBuilder))]
public class Toolbar: WebControl

public class ToolbarButtonCollection: CollectionBase

public class ToolbarButton: WebControl

As it can be deducted, the Toolbar lists several buttons which are
contained in the ToolBarButtonCollection class. The ToolbarButton owns
one Button and one ImageButton which only one is rendered depending on
a given property.The Design-time insertions are made automatically with
the IDE's editor. (a VS window which allows to add and remove items).
I have 2 questions/problems:

1.All the buttons that I create in design-time, are inserted as
individual controls in the page's code-behind. Which is rather annoying
and not wished at all. How could I revert this? My guess is that is
because i'm inheriting from WebControl and using the default Collection
Editor. So to assign an ID automatically to the control, the IDE must
insert the control into the code-behind.

An example is:

public class WebForm3 : System.Web.UI.Page
{
protected NetControls.Web.UI.ToolbarButton toolbarButton1;
protected NetControls.Web.UI.ToolbarButton toolbarButton2;
protected NetControls.Web.UI.Toolbar Toolbar1;

2. When I set the Visible property to false on the Toolbar, the value
is propagted to the Child Buttons. But when I re-set it to TRUE, all
the Buttons remain with the Visible="False" attribute on the aspx page.
My workaround is to set the property in the Toolbar's Render method,
but I think better would be on the Visible property set accesor.

Well I hope someone could help me on this...

Bye
Thanks in advance
KATLIM
 
M

Mike MacMillan

1.All the buttons that I create in design-time, are inserted as
individual controls in the page's code-behind

design time support is up to you to implement, if you are clicking a
control and adding it to the page via design time, VS will create the
proper(or not...) control references in the code behind. for better
control of what code actually gets written, id recommend not using the
designer...
2. When I set the Visible property to false on the Toolbar, the value
is propagted to the Child Buttons

this could be for a variety of reason, can you post the code for your
custom controls?

thanks,
Mike MacMillan




Hi, hope somebody could help me! ... I'm building a Toolbar Web Custom
Control. So i created 3 classes,

[ PersistChildren(false),
ParseChildren(false, "Buttons"),
ControlBuilder(typeof(ToolbarControlBuilder))]
public class Toolbar: WebControl

public class ToolbarButtonCollection: CollectionBase

public class ToolbarButton: WebControl

As it can be deducted, the Toolbar lists several buttons which are
contained in the ToolBarButtonCollection class. The ToolbarButton owns
one Button and one ImageButton which only one is rendered depending on
a given property.The Design-time insertions are made automatically with
the IDE's editor. (a VS window which allows to add and remove items).
I have 2 questions/problems:

1.All the buttons that I create in design-time, are inserted as
individual controls in the page's code-behind. Which is rather annoying
and not wished at all. How could I revert this? My guess is that is
because i'm inheriting from WebControl and using the default Collection
Editor. So to assign an ID automatically to the control, the IDE must
insert the control into the code-behind.

An example is:

public class WebForm3 : System.Web.UI.Page
{
protected NetControls.Web.UI.ToolbarButton toolbarButton1;
protected NetControls.Web.UI.ToolbarButton toolbarButton2;
protected NetControls.Web.UI.Toolbar Toolbar1;

2. When I set the Visible property to false on the Toolbar, the value
is propagted to the Child Buttons. But when I re-set it to TRUE, all
the Buttons remain with the Visible="False" attribute on the aspx page.
My workaround is to set the property in the Toolbar's Render method,
but I think better would be on the Visible property set accesor.

Well I hope someone could help me on this...

Bye
Thanks in advance
KATLIM
 
M

Mike MacMillan

1.All the buttons that I create in design-time, are inserted as
individual controls in the page's code-behind

design time support is up to you to implement, if you are clicking a
control and adding it to the page via design time, VS will create the
proper(or not...) control references in the code behind. for better
control of what code actually gets written, id recommend not using the
designer...
2. When I set the Visible property to false on the Toolbar, the value
is propagted to the Child Buttons

this could be for a variety of reasons, can you post the code for your
custom controls?

thanks,
Mike MacMillan




Hi, hope somebody could help me! ... I'm building a Toolbar Web Custom
Control. So i created 3 classes,

[ PersistChildren(false),
ParseChildren(false, "Buttons"),
ControlBuilder(typeof(ToolbarControlBuilder))]
public class Toolbar: WebControl

public class ToolbarButtonCollection: CollectionBase

public class ToolbarButton: WebControl

As it can be deducted, the Toolbar lists several buttons which are
contained in the ToolBarButtonCollection class. The ToolbarButton owns
one Button and one ImageButton which only one is rendered depending on
a given property.The Design-time insertions are made automatically with
the IDE's editor. (a VS window which allows to add and remove items).
I have 2 questions/problems:

1.All the buttons that I create in design-time, are inserted as
individual controls in the page's code-behind. Which is rather annoying
and not wished at all. How could I revert this? My guess is that is
because i'm inheriting from WebControl and using the default Collection
Editor. So to assign an ID automatically to the control, the IDE must
insert the control into the code-behind.

An example is:

public class WebForm3 : System.Web.UI.Page
{
protected NetControls.Web.UI.ToolbarButton toolbarButton1;
protected NetControls.Web.UI.ToolbarButton toolbarButton2;
protected NetControls.Web.UI.Toolbar Toolbar1;

2. When I set the Visible property to false on the Toolbar, the value
is propagted to the Child Buttons. But when I re-set it to TRUE, all
the Buttons remain with the Visible="False" attribute on the aspx page.
My workaround is to set the property in the Toolbar's Render method,
but I think better would be on the Visible property set accesor.

Well I hope someone could help me on this...

Bye
Thanks in advance
KATLIM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top