Child Controls inserted in Code Behind

Discussion in 'ASP .Net Building Controls' started by kruiz@tss.com.pe, Dec 23, 2005.

  1. Guest

    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
    , Dec 23, 2005
    #1
    1. Advertising

  2. > 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




    wrote:
    > 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
    Mike MacMillan, Dec 28, 2005
    #2
    1. Advertising

  3. > 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




    wrote:
    > 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
    Mike MacMillan, Dec 28, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    580
    Alphonse Giambrone
    Jun 28, 2003
  2. Norm  via DotNetMonster.com

    mixing HTML controls with code behind controls

    Norm via DotNetMonster.com, May 10, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,541
    Norm via DotNetMonster.com
    May 10, 2005
  3. Jeff Rodriguez
    Replies:
    23
    Views:
    1,116
    David Schwartz
    Dec 9, 2003
  4. John

    Non-code behind to code behind

    John, Feb 19, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    482
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 19, 2007
  5. Replies:
    0
    Views:
    202
Loading...

Share This Page