changing the default caption/id for an item in a collection editor?

Discussion in 'ASP .Net Building Controls' started by Jiho Han, Jan 30, 2004.

  1. Jiho Han

    Jiho Han Guest

    I have a custom control - deriving from WebControl - that contains a custom
    collection property as the default property.
    The collection implements IList and each item is also a custom control
    deriving from Panel control.
    I don't have a custom collection editor.

    Whenever I add my item through the collection editor, the member name
    generated by it are "myPanel1", "myPanel2", and so on where the the class
    name is MyPanel. And that member name is then put in the codebehind like
    so:

    protected MyPanel myPanel1;
    protected MyPanel myPanel2;

    Is there a way to override this behavior? Also, I figured setting the ID
    property on the item before it being added to the collection might do the
    trick but it didn't. So now I have in my codebehind declarations like above
    but in my HTML the thing is persisted like:

    <cc:MyPanel Caption="MyPanel1" ID="MyPanel1"></cc:MyPanel>

    And c# complains because it's case-sensitive.

    Another thing that bothers me more is this -

    My main control is derived from WebControl so ParseChildren(true) and
    PersistChildren(false) are the default. ParseChild(true, "MyPanels")
    actually since, I have the collection as the default property.

    So my code looks like this:

    [DesignSerializationVisibility(DesignSerializationVisibility.Content),
    PersistenceMode(PersistenceMode.InnerDefaultProperty),
    NotifyParentProperty(true)]
    public MyPanelCollection MyPanels
    {
    get
    {
    if (_myPanels == null)
    _myPanels = new MyPanelCollection(this);
    return _myPanels;
    }
    }

    It works. Maybe too well. Add 3 panels through the collection editor, it
    results in the following HTML.

    <cc:MyCustomControl ID="MyCustomControl1" runat="server">
    <cc:MyPanel Caption="myPanel1" ID="myPanel1"></cc:MyPanel>
    <cc:MyPanel Caption="myPanel2" ID="myPanel2"></cc:MyPanel>
    <cc:MyPanel Caption="myPanel3" ID="myPanel3"></cc:MyPanel>
    </cc:MyCustomControl>

    That's fine, but at the same time, those 3 MyPanels are added as child
    controls to my MyCustomControl1 and three of those statements get put into
    my codebehind. I go to the HTML view, add a fourth MyPanel following all
    conventions except for the number 4. I switch to the design view, open up
    the collection editor and now all my members are listed as "TabPage" which
    of course do not match any of the statements in my codebehind. And those
    three statements are wiped out. I don't know if that's the reason. What
    gives?

    And I don't understand why my MyPanel controls are being added as child
    controls in the first place. I don't add them in my code - actually I was
    but then I commented out CreateChildControls. Isn't ParseChildren(true)
    supposed to parse the nested content as properties? And so it correctly
    parses the default collection and adds individual MyPanel items to the
    collection correctly, but why are they added to MyCustomControl as child
    controls? Did I confuse anyone or is it just me?

    Help.
     
    Jiho Han, Jan 30, 2004
    #1
    1. Advertising

  2. hi Jiho,
    do you see these unwanted child panels in your toolbox as well ? Which ever
    the case I think your child panels are added in your code behind because
    your collections derieve from panel which in turn is a webcontrol.
    Try specifying the following to your collection to hide it from the toolbox
    and designtime, not sure if this is your case, however give it a try. I have
    a hunch that you added the toolboxitem(false) attribute and forgot to set
    the DesignTimeVisible to false as well ;P
    [ToolboxItem(false),DesignTimeVisible(false)]


    "Jiho Han" <> wrote in message
    news:%...
    > I have a custom control - deriving from WebControl - that contains a

    custom
    > collection property as the default property.
    > The collection implements IList and each item is also a custom control
    > deriving from Panel control.
    > I don't have a custom collection editor.
    >
    > Whenever I add my item through the collection editor, the member name
    > generated by it are "myPanel1", "myPanel2", and so on where the the class
    > name is MyPanel. And that member name is then put in the codebehind like
    > so:
    >
    > protected MyPanel myPanel1;
    > protected MyPanel myPanel2;
    >
    > Is there a way to override this behavior? Also, I figured setting the ID
    > property on the item before it being added to the collection might do the
    > trick but it didn't. So now I have in my codebehind declarations like

    above
    > but in my HTML the thing is persisted like:
    >
    > <cc:MyPanel Caption="MyPanel1" ID="MyPanel1"></cc:MyPanel>
    >
    > And c# complains because it's case-sensitive.
    >
    > Another thing that bothers me more is this -
    >
    > My main control is derived from WebControl so ParseChildren(true) and
    > PersistChildren(false) are the default. ParseChild(true, "MyPanels")
    > actually since, I have the collection as the default property.
    >
    > So my code looks like this:
    >
    > [DesignSerializationVisibility(DesignSerializationVisibility.Content),
    > PersistenceMode(PersistenceMode.InnerDefaultProperty),
    > NotifyParentProperty(true)]
    > public MyPanelCollection MyPanels
    > {
    > get
    > {
    > if (_myPanels == null)
    > _myPanels = new MyPanelCollection(this);
    > return _myPanels;
    > }
    > }
    >
    > It works. Maybe too well. Add 3 panels through the collection editor, it
    > results in the following HTML.
    >
    > <cc:MyCustomControl ID="MyCustomControl1" runat="server">
    > <cc:MyPanel Caption="myPanel1" ID="myPanel1"></cc:MyPanel>
    > <cc:MyPanel Caption="myPanel2" ID="myPanel2"></cc:MyPanel>
    > <cc:MyPanel Caption="myPanel3" ID="myPanel3"></cc:MyPanel>
    > </cc:MyCustomControl>
    >
    > That's fine, but at the same time, those 3 MyPanels are added as child
    > controls to my MyCustomControl1 and three of those statements get put into
    > my codebehind. I go to the HTML view, add a fourth MyPanel following all
    > conventions except for the number 4. I switch to the design view, open up
    > the collection editor and now all my members are listed as "TabPage" which
    > of course do not match any of the statements in my codebehind. And those
    > three statements are wiped out. I don't know if that's the reason. What
    > gives?
    >
    > And I don't understand why my MyPanel controls are being added as child
    > controls in the first place. I don't add them in my code - actually I was
    > but then I commented out CreateChildControls. Isn't ParseChildren(true)
    > supposed to parse the nested content as properties? And so it correctly
    > parses the default collection and adds individual MyPanel items to the
    > collection correctly, but why are they added to MyCustomControl as child
    > controls? Did I confuse anyone or is it just me?
    >
    > Help.
    >
    >
     
    Alessandro Zifiglio, Jan 31, 2004
    #2
    1. Advertising

  3. Jiho Han

    Jiho Han Guest

    Thanks Alessandro for your reponse.

    You're correct. I did set ToolBoxItem(false) but did not set
    DesignTimeVisible(false) at the same time. However having done that, it
    didn't change the outcome.
    Ok, this is what I am trying to do. I want to add my custom control to the
    form, edit it, add to its collection either via designer or in HTML but have
    it not write out the collection item (panel) declaration statements in my
    codebehind.

    In pursuit of this functionality, I've tried to use ShouldCodeSerialize
    method of the ControlDesigner class with no success. This stops it from
    writing out to the codebehind but at the same time, it stops HTML changes to
    take effect. I tried to attach a derived CodeDomSerializer to the control
    with no success. It simply didn't seem to do anything.

    One thing I've noticed is that whenever I tried to add any control type
    through the collection editor, it writes out the declaration statments to my
    codebehind class. When I derived my custom panel from Panel or Control, the
    statements were there. When I derived from nothing - thus object - it did
    not. I don't think it's the work of CollectionEditor per se. I've digging
    around for a bit, and it simply depends on the fact whether the component
    has a name or not. The name is not a property of the control but rather the
    Site that is attached to a component by the designer. When the collection
    editor creates the component, it asks the VS to create it via
    CreateComponent method while in HTML mode, it does not and so there is no
    Site property available, thus no Name. When there is no Name for a
    component, VS does not write out the statement to the codebehind I guess
    because it doesn't know what to name it :).

    At this point, I am really confused as to what's really going on and am
    losing patience. I just might change my Panel control so that it does not
    derive from a Control. That way it won't automaticall be added. And I'll
    just add the actual Panels in my CreateChildControls. I'll let you know how
    that works out. This is only the beginning since after this, I am trying to
    attach ReadWriteControlDesigner to my control so that the page developers
    can drag and drop other controls onto it. As you may have guess I'm trying
    to create a TabControl :) Page control uses TemplatedControlDesigner
    however and I am still wondering how these two are different and which one
    to use ultimately.

    Thanks for reading. If any Microsoft guys are reading this, I'd really
    appreciate some clarification.
    Jiho

    "Alessandro Zifiglio" <> wrote in
    message news:TgSSb.2008$...
    >
    > hi Jiho,
    > do you see these unwanted child panels in your toolbox as well ? Which

    ever
    > the case I think your child panels are added in your code behind because
    > your collections derieve from panel which in turn is a webcontrol.
    > Try specifying the following to your collection to hide it from the

    toolbox
    > and designtime, not sure if this is your case, however give it a try. I

    have
    > a hunch that you added the toolboxitem(false) attribute and forgot to set
    > the DesignTimeVisible to false as well ;P
    > [ToolboxItem(false),DesignTimeVisible(false)]
    >
    >
    > "Jiho Han" <> wrote in message
    > news:%...
    > > I have a custom control - deriving from WebControl - that contains a

    > custom
    > > collection property as the default property.
    > > The collection implements IList and each item is also a custom control
    > > deriving from Panel control.
    > > I don't have a custom collection editor.
    > >
    > > Whenever I add my item through the collection editor, the member name
    > > generated by it are "myPanel1", "myPanel2", and so on where the the

    class
    > > name is MyPanel. And that member name is then put in the codebehind

    like
    > > so:
    > >
    > > protected MyPanel myPanel1;
    > > protected MyPanel myPanel2;
    > >
    > > Is there a way to override this behavior? Also, I figured setting the

    ID
    > > property on the item before it being added to the collection might do

    the
    > > trick but it didn't. So now I have in my codebehind declarations like

    > above
    > > but in my HTML the thing is persisted like:
    > >
    > > <cc:MyPanel Caption="MyPanel1" ID="MyPanel1"></cc:MyPanel>
    > >
    > > And c# complains because it's case-sensitive.
    > >
    > > Another thing that bothers me more is this -
    > >
    > > My main control is derived from WebControl so ParseChildren(true) and
    > > PersistChildren(false) are the default. ParseChild(true, "MyPanels")
    > > actually since, I have the collection as the default property.
    > >
    > > So my code looks like this:
    > >
    > > [DesignSerializationVisibility(DesignSerializationVisibility.Content),
    > > PersistenceMode(PersistenceMode.InnerDefaultProperty),
    > > NotifyParentProperty(true)]
    > > public MyPanelCollection MyPanels
    > > {
    > > get
    > > {
    > > if (_myPanels == null)
    > > _myPanels = new MyPanelCollection(this);
    > > return _myPanels;
    > > }
    > > }
    > >
    > > It works. Maybe too well. Add 3 panels through the collection editor,

    it
    > > results in the following HTML.
    > >
    > > <cc:MyCustomControl ID="MyCustomControl1" runat="server">
    > > <cc:MyPanel Caption="myPanel1" ID="myPanel1"></cc:MyPanel>
    > > <cc:MyPanel Caption="myPanel2" ID="myPanel2"></cc:MyPanel>
    > > <cc:MyPanel Caption="myPanel3" ID="myPanel3"></cc:MyPanel>
    > > </cc:MyCustomControl>
    > >
    > > That's fine, but at the same time, those 3 MyPanels are added as child
    > > controls to my MyCustomControl1 and three of those statements get put

    into
    > > my codebehind. I go to the HTML view, add a fourth MyPanel following

    all
    > > conventions except for the number 4. I switch to the design view, open

    up
    > > the collection editor and now all my members are listed as "TabPage"

    which
    > > of course do not match any of the statements in my codebehind. And

    those
    > > three statements are wiped out. I don't know if that's the reason.

    What
    > > gives?
    > >
    > > And I don't understand why my MyPanel controls are being added as child
    > > controls in the first place. I don't add them in my code - actually I

    was
    > > but then I commented out CreateChildControls. Isn't ParseChildren(true)
    > > supposed to parse the nested content as properties? And so it correctly
    > > parses the default collection and adds individual MyPanel items to the
    > > collection correctly, but why are they added to MyCustomControl as child
    > > controls? Did I confuse anyone or is it just me?
    > >
    > > Help.
    > >
    > >

    >
    >
     
    Jiho Han, Feb 2, 2004
    #3
  4. Jiho, just a thought but if this is not working for you, and y our already
    going to make changes to your control, try looking at the source code thats
    available with the IE web controls. Theres a TabStrip control in there. They
    are not using panels but I'm sure you could use some implementation
    techniques, ideas from them.
    "Jiho Han" <> wrote in message
    news:%...
    > Thanks Alessandro for your reponse.
    >
    > You're correct. I did set ToolBoxItem(false) but did not set
    > DesignTimeVisible(false) at the same time. However having done that, it
    > didn't change the outcome.
    > Ok, this is what I am trying to do. I want to add my custom control to

    the
    > form, edit it, add to its collection either via designer or in HTML but

    have
    > it not write out the collection item (panel) declaration statements in my
    > codebehind.
    >
    > In pursuit of this functionality, I've tried to use ShouldCodeSerialize
    > method of the ControlDesigner class with no success. This stops it from
    > writing out to the codebehind but at the same time, it stops HTML changes

    to
    > take effect. I tried to attach a derived CodeDomSerializer to the control
    > with no success. It simply didn't seem to do anything.
    >
    > One thing I've noticed is that whenever I tried to add any control type
    > through the collection editor, it writes out the declaration statments to

    my
    > codebehind class. When I derived my custom panel from Panel or Control,

    the
    > statements were there. When I derived from nothing - thus object - it did
    > not. I don't think it's the work of CollectionEditor per se. I've

    digging
    > around for a bit, and it simply depends on the fact whether the component
    > has a name or not. The name is not a property of the control but rather

    the
    > Site that is attached to a component by the designer. When the collection
    > editor creates the component, it asks the VS to create it via
    > CreateComponent method while in HTML mode, it does not and so there is no
    > Site property available, thus no Name. When there is no Name for a
    > component, VS does not write out the statement to the codebehind I guess
    > because it doesn't know what to name it :).
    >
    > At this point, I am really confused as to what's really going on and am
    > losing patience. I just might change my Panel control so that it does not
    > derive from a Control. That way it won't automaticall be added. And I'll
    > just add the actual Panels in my CreateChildControls. I'll let you know

    how
    > that works out. This is only the beginning since after this, I am trying

    to
    > attach ReadWriteControlDesigner to my control so that the page developers
    > can drag and drop other controls onto it. As you may have guess I'm

    trying
    > to create a TabControl :) Page control uses TemplatedControlDesigner
    > however and I am still wondering how these two are different and which one
    > to use ultimately.
    >
    > Thanks for reading. If any Microsoft guys are reading this, I'd really
    > appreciate some clarification.
    > Jiho
    >
    > "Alessandro Zifiglio" <> wrote in
    > message news:TgSSb.2008$...
    > >
    > > hi Jiho,
    > > do you see these unwanted child panels in your toolbox as well ? Which

    > ever
    > > the case I think your child panels are added in your code behind because
    > > your collections derieve from panel which in turn is a webcontrol.
    > > Try specifying the following to your collection to hide it from the

    > toolbox
    > > and designtime, not sure if this is your case, however give it a try. I

    > have
    > > a hunch that you added the toolboxitem(false) attribute and forgot to

    set
    > > the DesignTimeVisible to false as well ;P
    > > [ToolboxItem(false),DesignTimeVisible(false)]
    > >
    > >
    > > "Jiho Han" <> wrote in message
    > > news:%...
    > > > I have a custom control - deriving from WebControl - that contains a

    > > custom
    > > > collection property as the default property.
    > > > The collection implements IList and each item is also a custom control
    > > > deriving from Panel control.
    > > > I don't have a custom collection editor.
    > > >
    > > > Whenever I add my item through the collection editor, the member name
    > > > generated by it are "myPanel1", "myPanel2", and so on where the the

    > class
    > > > name is MyPanel. And that member name is then put in the codebehind

    > like
    > > > so:
    > > >
    > > > protected MyPanel myPanel1;
    > > > protected MyPanel myPanel2;
    > > >
    > > > Is there a way to override this behavior? Also, I figured setting the

    > ID
    > > > property on the item before it being added to the collection might do

    > the
    > > > trick but it didn't. So now I have in my codebehind declarations like

    > > above
    > > > but in my HTML the thing is persisted like:
    > > >
    > > > <cc:MyPanel Caption="MyPanel1" ID="MyPanel1"></cc:MyPanel>
    > > >
    > > > And c# complains because it's case-sensitive.
    > > >
    > > > Another thing that bothers me more is this -
    > > >
    > > > My main control is derived from WebControl so ParseChildren(true) and
    > > > PersistChildren(false) are the default. ParseChild(true, "MyPanels")
    > > > actually since, I have the collection as the default property.
    > > >
    > > > So my code looks like this:
    > > >
    > > > [DesignSerializationVisibility(DesignSerializationVisibility.Content),
    > > > PersistenceMode(PersistenceMode.InnerDefaultProperty),
    > > > NotifyParentProperty(true)]
    > > > public MyPanelCollection MyPanels
    > > > {
    > > > get
    > > > {
    > > > if (_myPanels == null)
    > > > _myPanels = new MyPanelCollection(this);
    > > > return _myPanels;
    > > > }
    > > > }
    > > >
    > > > It works. Maybe too well. Add 3 panels through the collection

    editor,
    > it
    > > > results in the following HTML.
    > > >
    > > > <cc:MyCustomControl ID="MyCustomControl1" runat="server">
    > > > <cc:MyPanel Caption="myPanel1" ID="myPanel1"></cc:MyPanel>
    > > > <cc:MyPanel Caption="myPanel2" ID="myPanel2"></cc:MyPanel>
    > > > <cc:MyPanel Caption="myPanel3" ID="myPanel3"></cc:MyPanel>
    > > > </cc:MyCustomControl>
    > > >
    > > > That's fine, but at the same time, those 3 MyPanels are added as child
    > > > controls to my MyCustomControl1 and three of those statements get put

    > into
    > > > my codebehind. I go to the HTML view, add a fourth MyPanel following

    > all
    > > > conventions except for the number 4. I switch to the design view,

    open
    > up
    > > > the collection editor and now all my members are listed as "TabPage"

    > which
    > > > of course do not match any of the statements in my codebehind. And

    > those
    > > > three statements are wiped out. I don't know if that's the reason.

    > What
    > > > gives?
    > > >
    > > > And I don't understand why my MyPanel controls are being added as

    child
    > > > controls in the first place. I don't add them in my code - actually I

    > was
    > > > but then I commented out CreateChildControls. Isn't

    ParseChildren(true)
    > > > supposed to parse the nested content as properties? And so it

    correctly
    > > > parses the default collection and adds individual MyPanel items to the
    > > > collection correctly, but why are they added to MyCustomControl as

    child
    > > > controls? Did I confuse anyone or is it just me?
    > > >
    > > > Help.
    > > >
    > > >

    > >
    > >

    >
    >
     
    Alessandro Zifiglio, Feb 3, 2004
    #4
  5. Jiho Han

    Jiho Han Guest

    Thanks for keeping up Alessandro.

    Really, sometimes solutions are in the simplest places you've never thought
    to look because it's so simple.
    What I ended up doing is that I went back to my original design where my
    tabs are derived from Panel - it really doesn't matter if it is any other
    Control though - and created a custom collection editor and overrode the
    method CreateInstance. In it I create a new instance of the tab panel and
    return it. This way there is no site for the control and it behaves
    identically as when the control is parsed from HTML. I really didn't want
    those declaration statements in my codebehind for each tab anyway, so it's
    working out perfectly.

    BTW, do you know if they have sources available for those IE web controls?
    Probably not eh?
    Thanks

    "Alessandro Zifiglio" <> wrote in
    message news:KqNTb.2948$...
    > Jiho, just a thought but if this is not working for you, and y our already
    > going to make changes to your control, try looking at the source code

    thats
    > available with the IE web controls. Theres a TabStrip control in there.

    They
    > are not using panels but I'm sure you could use some implementation
    > techniques, ideas from them.
    > "Jiho Han" <> wrote in message
    > news:%...
    > > Thanks Alessandro for your reponse.
    > >
    > > You're correct. I did set ToolBoxItem(false) but did not set
    > > DesignTimeVisible(false) at the same time. However having done that, it
    > > didn't change the outcome.
    > > Ok, this is what I am trying to do. I want to add my custom control to

    > the
    > > form, edit it, add to its collection either via designer or in HTML but

    > have
    > > it not write out the collection item (panel) declaration statements in

    my
    > > codebehind.
    > >
    > > In pursuit of this functionality, I've tried to use ShouldCodeSerialize
    > > method of the ControlDesigner class with no success. This stops it from
    > > writing out to the codebehind but at the same time, it stops HTML

    changes
    > to
    > > take effect. I tried to attach a derived CodeDomSerializer to the

    control
    > > with no success. It simply didn't seem to do anything.
    > >
    > > One thing I've noticed is that whenever I tried to add any control type
    > > through the collection editor, it writes out the declaration statments

    to
    > my
    > > codebehind class. When I derived my custom panel from Panel or Control,

    > the
    > > statements were there. When I derived from nothing - thus object - it

    did
    > > not. I don't think it's the work of CollectionEditor per se. I've

    > digging
    > > around for a bit, and it simply depends on the fact whether the

    component
    > > has a name or not. The name is not a property of the control but rather

    > the
    > > Site that is attached to a component by the designer. When the

    collection
    > > editor creates the component, it asks the VS to create it via
    > > CreateComponent method while in HTML mode, it does not and so there is

    no
    > > Site property available, thus no Name. When there is no Name for a
    > > component, VS does not write out the statement to the codebehind I guess
    > > because it doesn't know what to name it :).
    > >
    > > At this point, I am really confused as to what's really going on and am
    > > losing patience. I just might change my Panel control so that it does

    not
    > > derive from a Control. That way it won't automaticall be added. And

    I'll
    > > just add the actual Panels in my CreateChildControls. I'll let you know

    > how
    > > that works out. This is only the beginning since after this, I am

    trying
    > to
    > > attach ReadWriteControlDesigner to my control so that the page

    developers
    > > can drag and drop other controls onto it. As you may have guess I'm

    > trying
    > > to create a TabControl :) Page control uses TemplatedControlDesigner
    > > however and I am still wondering how these two are different and which

    one
    > > to use ultimately.
    > >
    > > Thanks for reading. If any Microsoft guys are reading this, I'd really
    > > appreciate some clarification.
    > > Jiho
    > >
    > > "Alessandro Zifiglio" <> wrote in
    > > message news:TgSSb.2008$...
    > > >
    > > > hi Jiho,
    > > > do you see these unwanted child panels in your toolbox as well ? Which

    > > ever
    > > > the case I think your child panels are added in your code behind

    because
    > > > your collections derieve from panel which in turn is a webcontrol.
    > > > Try specifying the following to your collection to hide it from the

    > > toolbox
    > > > and designtime, not sure if this is your case, however give it a try.

    I
    > > have
    > > > a hunch that you added the toolboxitem(false) attribute and forgot to

    > set
    > > > the DesignTimeVisible to false as well ;P
    > > > [ToolboxItem(false),DesignTimeVisible(false)]
    > > >
    > > >
    > > > "Jiho Han" <> wrote in message
    > > > news:%...
    > > > > I have a custom control - deriving from WebControl - that contains a
    > > > custom
    > > > > collection property as the default property.
    > > > > The collection implements IList and each item is also a custom

    control
    > > > > deriving from Panel control.
    > > > > I don't have a custom collection editor.
    > > > >
    > > > > Whenever I add my item through the collection editor, the member

    name
    > > > > generated by it are "myPanel1", "myPanel2", and so on where the the

    > > class
    > > > > name is MyPanel. And that member name is then put in the codebehind

    > > like
    > > > > so:
    > > > >
    > > > > protected MyPanel myPanel1;
    > > > > protected MyPanel myPanel2;
    > > > >
    > > > > Is there a way to override this behavior? Also, I figured setting

    the
    > > ID
    > > > > property on the item before it being added to the collection might

    do
    > > the
    > > > > trick but it didn't. So now I have in my codebehind declarations

    like
    > > > above
    > > > > but in my HTML the thing is persisted like:
    > > > >
    > > > > <cc:MyPanel Caption="MyPanel1" ID="MyPanel1"></cc:MyPanel>
    > > > >
    > > > > And c# complains because it's case-sensitive.
    > > > >
    > > > > Another thing that bothers me more is this -
    > > > >
    > > > > My main control is derived from WebControl so ParseChildren(true)

    and
    > > > > PersistChildren(false) are the default. ParseChild(true,

    "MyPanels")
    > > > > actually since, I have the collection as the default property.
    > > > >
    > > > > So my code looks like this:
    > > > >
    > > > >

    [DesignSerializationVisibility(DesignSerializationVisibility.Content),
    > > > > PersistenceMode(PersistenceMode.InnerDefaultProperty),
    > > > > NotifyParentProperty(true)]
    > > > > public MyPanelCollection MyPanels
    > > > > {
    > > > > get
    > > > > {
    > > > > if (_myPanels == null)
    > > > > _myPanels = new MyPanelCollection(this);
    > > > > return _myPanels;
    > > > > }
    > > > > }
    > > > >
    > > > > It works. Maybe too well. Add 3 panels through the collection

    > editor,
    > > it
    > > > > results in the following HTML.
    > > > >
    > > > > <cc:MyCustomControl ID="MyCustomControl1" runat="server">
    > > > > <cc:MyPanel Caption="myPanel1" ID="myPanel1"></cc:MyPanel>
    > > > > <cc:MyPanel Caption="myPanel2" ID="myPanel2"></cc:MyPanel>
    > > > > <cc:MyPanel Caption="myPanel3" ID="myPanel3"></cc:MyPanel>
    > > > > </cc:MyCustomControl>
    > > > >
    > > > > That's fine, but at the same time, those 3 MyPanels are added as

    child
    > > > > controls to my MyCustomControl1 and three of those statements get

    put
    > > into
    > > > > my codebehind. I go to the HTML view, add a fourth MyPanel

    following
    > > all
    > > > > conventions except for the number 4. I switch to the design view,

    > open
    > > up
    > > > > the collection editor and now all my members are listed as "TabPage"

    > > which
    > > > > of course do not match any of the statements in my codebehind. And

    > > those
    > > > > three statements are wiped out. I don't know if that's the reason.

    > > What
    > > > > gives?
    > > > >
    > > > > And I don't understand why my MyPanel controls are being added as

    > child
    > > > > controls in the first place. I don't add them in my code - actually

    I
    > > was
    > > > > but then I commented out CreateChildControls. Isn't

    > ParseChildren(true)
    > > > > supposed to parse the nested content as properties? And so it

    > correctly
    > > > > parses the default collection and adds individual MyPanel items to

    the
    > > > > collection correctly, but why are they added to MyCustomControl as

    > child
    > > > > controls? Did I confuse anyone or is it just me?
    > > > >
    > > > > Help.
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Jiho Han, Feb 3, 2004
    #5
  6. Jiho Han

    Jiho Han Guest

    Never mind, it does come with the source. I see that the tab functionality
    is implemented as two separate controls a tabstrip and multipage, which is
    ok I guess but the multipage control doesn't support drag and drop of other
    controls which is unfortunate...

    "Jiho Han" <> wrote in message
    news:...
    > Thanks for keeping up Alessandro.
    >
    > Really, sometimes solutions are in the simplest places you've never

    thought
    > to look because it's so simple.
    > What I ended up doing is that I went back to my original design where my
    > tabs are derived from Panel - it really doesn't matter if it is any other
    > Control though - and created a custom collection editor and overrode the
    > method CreateInstance. In it I create a new instance of the tab panel and
    > return it. This way there is no site for the control and it behaves
    > identically as when the control is parsed from HTML. I really didn't want
    > those declaration statements in my codebehind for each tab anyway, so it's
    > working out perfectly.
    >
    > BTW, do you know if they have sources available for those IE web controls?
    > Probably not eh?
    > Thanks
    >
    > "Alessandro Zifiglio" <> wrote in
    > message news:KqNTb.2948$...
    > > Jiho, just a thought but if this is not working for you, and y our

    already
    > > going to make changes to your control, try looking at the source code

    > thats
    > > available with the IE web controls. Theres a TabStrip control in there.

    > They
    > > are not using panels but I'm sure you could use some implementation
    > > techniques, ideas from them.
    > > "Jiho Han" <> wrote in message
    > > news:%...
    > > > Thanks Alessandro for your reponse.
    > > >
    > > > You're correct. I did set ToolBoxItem(false) but did not set
    > > > DesignTimeVisible(false) at the same time. However having done that,

    it
    > > > didn't change the outcome.
    > > > Ok, this is what I am trying to do. I want to add my custom control

    to
    > > the
    > > > form, edit it, add to its collection either via designer or in HTML

    but
    > > have
    > > > it not write out the collection item (panel) declaration statements in

    > my
    > > > codebehind.
    > > >
    > > > In pursuit of this functionality, I've tried to use

    ShouldCodeSerialize
    > > > method of the ControlDesigner class with no success. This stops it

    from
    > > > writing out to the codebehind but at the same time, it stops HTML

    > changes
    > > to
    > > > take effect. I tried to attach a derived CodeDomSerializer to the

    > control
    > > > with no success. It simply didn't seem to do anything.
    > > >
    > > > One thing I've noticed is that whenever I tried to add any control

    type
    > > > through the collection editor, it writes out the declaration statments

    > to
    > > my
    > > > codebehind class. When I derived my custom panel from Panel or

    Control,
    > > the
    > > > statements were there. When I derived from nothing - thus object - it

    > did
    > > > not. I don't think it's the work of CollectionEditor per se. I've

    > > digging
    > > > around for a bit, and it simply depends on the fact whether the

    > component
    > > > has a name or not. The name is not a property of the control but

    rather
    > > the
    > > > Site that is attached to a component by the designer. When the

    > collection
    > > > editor creates the component, it asks the VS to create it via
    > > > CreateComponent method while in HTML mode, it does not and so there is

    > no
    > > > Site property available, thus no Name. When there is no Name for a
    > > > component, VS does not write out the statement to the codebehind I

    guess
    > > > because it doesn't know what to name it :).
    > > >
    > > > At this point, I am really confused as to what's really going on and

    am
    > > > losing patience. I just might change my Panel control so that it does

    > not
    > > > derive from a Control. That way it won't automaticall be added. And

    > I'll
    > > > just add the actual Panels in my CreateChildControls. I'll let you

    know
    > > how
    > > > that works out. This is only the beginning since after this, I am

    > trying
    > > to
    > > > attach ReadWriteControlDesigner to my control so that the page

    > developers
    > > > can drag and drop other controls onto it. As you may have guess I'm

    > > trying
    > > > to create a TabControl :) Page control uses TemplatedControlDesigner
    > > > however and I am still wondering how these two are different and which

    > one
    > > > to use ultimately.
    > > >
    > > > Thanks for reading. If any Microsoft guys are reading this, I'd

    really
    > > > appreciate some clarification.
    > > > Jiho
    > > >
    > > > "Alessandro Zifiglio" <> wrote

    in
    > > > message news:TgSSb.2008$...
    > > > >
    > > > > hi Jiho,
    > > > > do you see these unwanted child panels in your toolbox as well ?

    Which
    > > > ever
    > > > > the case I think your child panels are added in your code behind

    > because
    > > > > your collections derieve from panel which in turn is a webcontrol.
    > > > > Try specifying the following to your collection to hide it from the
    > > > toolbox
    > > > > and designtime, not sure if this is your case, however give it a

    try.
    > I
    > > > have
    > > > > a hunch that you added the toolboxitem(false) attribute and forgot

    to
    > > set
    > > > > the DesignTimeVisible to false as well ;P
    > > > > [ToolboxItem(false),DesignTimeVisible(false)]
    > > > >
    > > > >
    > > > > "Jiho Han" <> wrote in message
    > > > > news:%...
    > > > > > I have a custom control - deriving from WebControl - that contains

    a
    > > > > custom
    > > > > > collection property as the default property.
    > > > > > The collection implements IList and each item is also a custom

    > control
    > > > > > deriving from Panel control.
    > > > > > I don't have a custom collection editor.
    > > > > >
    > > > > > Whenever I add my item through the collection editor, the member

    > name
    > > > > > generated by it are "myPanel1", "myPanel2", and so on where the

    the
    > > > class
    > > > > > name is MyPanel. And that member name is then put in the

    codebehind
    > > > like
    > > > > > so:
    > > > > >
    > > > > > protected MyPanel myPanel1;
    > > > > > protected MyPanel myPanel2;
    > > > > >
    > > > > > Is there a way to override this behavior? Also, I figured setting

    > the
    > > > ID
    > > > > > property on the item before it being added to the collection might

    > do
    > > > the
    > > > > > trick but it didn't. So now I have in my codebehind declarations

    > like
    > > > > above
    > > > > > but in my HTML the thing is persisted like:
    > > > > >
    > > > > > <cc:MyPanel Caption="MyPanel1" ID="MyPanel1"></cc:MyPanel>
    > > > > >
    > > > > > And c# complains because it's case-sensitive.
    > > > > >
    > > > > > Another thing that bothers me more is this -
    > > > > >
    > > > > > My main control is derived from WebControl so ParseChildren(true)

    > and
    > > > > > PersistChildren(false) are the default. ParseChild(true,

    > "MyPanels")
    > > > > > actually since, I have the collection as the default property.
    > > > > >
    > > > > > So my code looks like this:
    > > > > >
    > > > > >

    > [DesignSerializationVisibility(DesignSerializationVisibility.Content),
    > > > > > PersistenceMode(PersistenceMode.InnerDefaultProperty),
    > > > > > NotifyParentProperty(true)]
    > > > > > public MyPanelCollection MyPanels
    > > > > > {
    > > > > > get
    > > > > > {
    > > > > > if (_myPanels == null)
    > > > > > _myPanels = new MyPanelCollection(this);
    > > > > > return _myPanels;
    > > > > > }
    > > > > > }
    > > > > >
    > > > > > It works. Maybe too well. Add 3 panels through the collection

    > > editor,
    > > > it
    > > > > > results in the following HTML.
    > > > > >
    > > > > > <cc:MyCustomControl ID="MyCustomControl1" runat="server">
    > > > > > <cc:MyPanel Caption="myPanel1" ID="myPanel1"></cc:MyPanel>
    > > > > > <cc:MyPanel Caption="myPanel2" ID="myPanel2"></cc:MyPanel>
    > > > > > <cc:MyPanel Caption="myPanel3" ID="myPanel3"></cc:MyPanel>
    > > > > > </cc:MyCustomControl>
    > > > > >
    > > > > > That's fine, but at the same time, those 3 MyPanels are added as

    > child
    > > > > > controls to my MyCustomControl1 and three of those statements get

    > put
    > > > into
    > > > > > my codebehind. I go to the HTML view, add a fourth MyPanel

    > following
    > > > all
    > > > > > conventions except for the number 4. I switch to the design view,

    > > open
    > > > up
    > > > > > the collection editor and now all my members are listed as

    "TabPage"
    > > > which
    > > > > > of course do not match any of the statements in my codebehind.

    And
    > > > those
    > > > > > three statements are wiped out. I don't know if that's the

    reason.
    > > > What
    > > > > > gives?
    > > > > >
    > > > > > And I don't understand why my MyPanel controls are being added as

    > > child
    > > > > > controls in the first place. I don't add them in my code -

    actually
    > I
    > > > was
    > > > > > but then I commented out CreateChildControls. Isn't

    > > ParseChildren(true)
    > > > > > supposed to parse the nested content as properties? And so it

    > > correctly
    > > > > > parses the default collection and adds individual MyPanel items to

    > the
    > > > > > collection correctly, but why are they added to MyCustomControl as

    > > child
    > > > > > controls? Did I confuse anyone or is it just me?
    > > > > >
    > > > > > Help.
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Jiho Han, Feb 3, 2004
    #6
  7. Yeah, combing the tabstrip with the multipage gives you the behaviour your
    trying to achieve with your custom control, however you've managed to get
    your control working and resolved. Most times when you dig too deep only you
    the author can come up with the solutions and someone else will only slow
    you down. This is one of those cases ;P

    Glad you solved Jiho ;)
    "Jiho Han" <> wrote in message
    news:eql5%...
    > Never mind, it does come with the source. I see that the tab

    functionality
    > is implemented as two separate controls a tabstrip and multipage, which is
    > ok I guess but the multipage control doesn't support drag and drop of

    other
    > controls which is unfortunate...
    >
    > "Jiho Han" <> wrote in message
    > news:...
    > > Thanks for keeping up Alessandro.
    > >
    > > Really, sometimes solutions are in the simplest places you've never

    > thought
    > > to look because it's so simple.
    > > What I ended up doing is that I went back to my original design where my
    > > tabs are derived from Panel - it really doesn't matter if it is any

    other
    > > Control though - and created a custom collection editor and overrode the
    > > method CreateInstance. In it I create a new instance of the tab panel

    and
    > > return it. This way there is no site for the control and it behaves
    > > identically as when the control is parsed from HTML. I really didn't

    want
    > > those declaration statements in my codebehind for each tab anyway, so

    it's
    > > working out perfectly.
    > >
    > > BTW, do you know if they have sources available for those IE web

    controls?
    > > Probably not eh?
    > > Thanks
    > >
    > > "Alessandro Zifiglio" <> wrote in
    > > message news:KqNTb.2948$...
    > > > Jiho, just a thought but if this is not working for you, and y our

    > already
    > > > going to make changes to your control, try looking at the source code

    > > thats
    > > > available with the IE web controls. Theres a TabStrip control in

    there.
    > > They
    > > > are not using panels but I'm sure you could use some implementation
    > > > techniques, ideas from them.
    > > > "Jiho Han" <> wrote in message
    > > > news:%...
    > > > > Thanks Alessandro for your reponse.
    > > > >
    > > > > You're correct. I did set ToolBoxItem(false) but did not set
    > > > > DesignTimeVisible(false) at the same time. However having done

    that,
    > it
    > > > > didn't change the outcome.
    > > > > Ok, this is what I am trying to do. I want to add my custom control

    > to
    > > > the
    > > > > form, edit it, add to its collection either via designer or in HTML

    > but
    > > > have
    > > > > it not write out the collection item (panel) declaration statements

    in
    > > my
    > > > > codebehind.
    > > > >
    > > > > In pursuit of this functionality, I've tried to use

    > ShouldCodeSerialize
    > > > > method of the ControlDesigner class with no success. This stops it

    > from
    > > > > writing out to the codebehind but at the same time, it stops HTML

    > > changes
    > > > to
    > > > > take effect. I tried to attach a derived CodeDomSerializer to the

    > > control
    > > > > with no success. It simply didn't seem to do anything.
    > > > >
    > > > > One thing I've noticed is that whenever I tried to add any control

    > type
    > > > > through the collection editor, it writes out the declaration

    statments
    > > to
    > > > my
    > > > > codebehind class. When I derived my custom panel from Panel or

    > Control,
    > > > the
    > > > > statements were there. When I derived from nothing - thus object -

    it
    > > did
    > > > > not. I don't think it's the work of CollectionEditor per se. I've
    > > > digging
    > > > > around for a bit, and it simply depends on the fact whether the

    > > component
    > > > > has a name or not. The name is not a property of the control but

    > rather
    > > > the
    > > > > Site that is attached to a component by the designer. When the

    > > collection
    > > > > editor creates the component, it asks the VS to create it via
    > > > > CreateComponent method while in HTML mode, it does not and so there

    is
    > > no
    > > > > Site property available, thus no Name. When there is no Name for a
    > > > > component, VS does not write out the statement to the codebehind I

    > guess
    > > > > because it doesn't know what to name it :).
    > > > >
    > > > > At this point, I am really confused as to what's really going on and

    > am
    > > > > losing patience. I just might change my Panel control so that it

    does
    > > not
    > > > > derive from a Control. That way it won't automaticall be added.

    And
    > > I'll
    > > > > just add the actual Panels in my CreateChildControls. I'll let you

    > know
    > > > how
    > > > > that works out. This is only the beginning since after this, I am

    > > trying
    > > > to
    > > > > attach ReadWriteControlDesigner to my control so that the page

    > > developers
    > > > > can drag and drop other controls onto it. As you may have guess I'm
    > > > trying
    > > > > to create a TabControl :) Page control uses

    TemplatedControlDesigner
    > > > > however and I am still wondering how these two are different and

    which
    > > one
    > > > > to use ultimately.
    > > > >
    > > > > Thanks for reading. If any Microsoft guys are reading this, I'd

    > really
    > > > > appreciate some clarification.
    > > > > Jiho
    > > > >
    > > > > "Alessandro Zifiglio" <> wrote

    > in
    > > > > message news:TgSSb.2008$...
    > > > > >
    > > > > > hi Jiho,
    > > > > > do you see these unwanted child panels in your toolbox as well ?

    > Which
    > > > > ever
    > > > > > the case I think your child panels are added in your code behind

    > > because
    > > > > > your collections derieve from panel which in turn is a webcontrol.
    > > > > > Try specifying the following to your collection to hide it from

    the
    > > > > toolbox
    > > > > > and designtime, not sure if this is your case, however give it a

    > try.
    > > I
    > > > > have
    > > > > > a hunch that you added the toolboxitem(false) attribute and forgot

    > to
    > > > set
    > > > > > the DesignTimeVisible to false as well ;P
    > > > > > [ToolboxItem(false),DesignTimeVisible(false)]
    > > > > >
    > > > > >
    > > > > > "Jiho Han" <> wrote in message
    > > > > > news:%...
    > > > > > > I have a custom control - deriving from WebControl - that

    contains
    > a
    > > > > > custom
    > > > > > > collection property as the default property.
    > > > > > > The collection implements IList and each item is also a custom

    > > control
    > > > > > > deriving from Panel control.
    > > > > > > I don't have a custom collection editor.
    > > > > > >
    > > > > > > Whenever I add my item through the collection editor, the member

    > > name
    > > > > > > generated by it are "myPanel1", "myPanel2", and so on where the

    > the
    > > > > class
    > > > > > > name is MyPanel. And that member name is then put in the

    > codebehind
    > > > > like
    > > > > > > so:
    > > > > > >
    > > > > > > protected MyPanel myPanel1;
    > > > > > > protected MyPanel myPanel2;
    > > > > > >
    > > > > > > Is there a way to override this behavior? Also, I figured

    setting
    > > the
    > > > > ID
    > > > > > > property on the item before it being added to the collection

    might
    > > do
    > > > > the
    > > > > > > trick but it didn't. So now I have in my codebehind

    declarations
    > > like
    > > > > > above
    > > > > > > but in my HTML the thing is persisted like:
    > > > > > >
    > > > > > > <cc:MyPanel Caption="MyPanel1" ID="MyPanel1"></cc:MyPanel>
    > > > > > >
    > > > > > > And c# complains because it's case-sensitive.
    > > > > > >
    > > > > > > Another thing that bothers me more is this -
    > > > > > >
    > > > > > > My main control is derived from WebControl so

    ParseChildren(true)
    > > and
    > > > > > > PersistChildren(false) are the default. ParseChild(true,

    > > "MyPanels")
    > > > > > > actually since, I have the collection as the default property.
    > > > > > >
    > > > > > > So my code looks like this:
    > > > > > >
    > > > > > >

    > > [DesignSerializationVisibility(DesignSerializationVisibility.Content),
    > > > > > > PersistenceMode(PersistenceMode.InnerDefaultProperty),
    > > > > > > NotifyParentProperty(true)]
    > > > > > > public MyPanelCollection MyPanels
    > > > > > > {
    > > > > > > get
    > > > > > > {
    > > > > > > if (_myPanels == null)
    > > > > > > _myPanels = new MyPanelCollection(this);
    > > > > > > return _myPanels;
    > > > > > > }
    > > > > > > }
    > > > > > >
    > > > > > > It works. Maybe too well. Add 3 panels through the collection
    > > > editor,
    > > > > it
    > > > > > > results in the following HTML.
    > > > > > >
    > > > > > > <cc:MyCustomControl ID="MyCustomControl1" runat="server">
    > > > > > > <cc:MyPanel Caption="myPanel1"

    ID="myPanel1"></cc:MyPanel>
    > > > > > > <cc:MyPanel Caption="myPanel2"

    ID="myPanel2"></cc:MyPanel>
    > > > > > > <cc:MyPanel Caption="myPanel3"

    ID="myPanel3"></cc:MyPanel>
    > > > > > > </cc:MyCustomControl>
    > > > > > >
    > > > > > > That's fine, but at the same time, those 3 MyPanels are added as

    > > child
    > > > > > > controls to my MyCustomControl1 and three of those statements

    get
    > > put
    > > > > into
    > > > > > > my codebehind. I go to the HTML view, add a fourth MyPanel

    > > following
    > > > > all
    > > > > > > conventions except for the number 4. I switch to the design

    view,
    > > > open
    > > > > up
    > > > > > > the collection editor and now all my members are listed as

    > "TabPage"
    > > > > which
    > > > > > > of course do not match any of the statements in my codebehind.

    > And
    > > > > those
    > > > > > > three statements are wiped out. I don't know if that's the

    > reason.
    > > > > What
    > > > > > > gives?
    > > > > > >
    > > > > > > And I don't understand why my MyPanel controls are being added

    as
    > > > child
    > > > > > > controls in the first place. I don't add them in my code -

    > actually
    > > I
    > > > > was
    > > > > > > but then I commented out CreateChildControls. Isn't
    > > > ParseChildren(true)
    > > > > > > supposed to parse the nested content as properties? And so it
    > > > correctly
    > > > > > > parses the default collection and adds individual MyPanel items

    to
    > > the
    > > > > > > collection correctly, but why are they added to MyCustomControl

    as
    > > > child
    > > > > > > controls? Did I confuse anyone or is it just me?
    > > > > > >
    > > > > > > Help.
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Alessandro Zifiglio, Feb 3, 2004
    #7
  8. almost forgot. If your looking for drag and drop, and your control is a
    templated control then go ahead and derive from the
    TemplatedControlDesigner. If you have used the datalist control then you
    will notice that you are able to drag and drop controls into its various
    templates. This is the designer it uses, or atleast i think ;P
    Its the same designer I use in my control too and it works great. I havent
    had a chance to mess with the readwriteControlDesigner but in the docs it
    says if you dont have templates and still want drag and drop this is the one
    to use. Theres a good non-working example on MSDN for the
    templatedControlDesigner --It will not run for you as is without you having
    to make changes to some of the code in the sample and debugging it but it
    does showcases most of the features and implementation. Nice sample but very
    buggy code. ;P
    http://msdn.microsoft.com/library/d...conwebformsdataboundcontroldesignersample.asp


    "Alessandro Zifiglio" <> wrote in
    message news:zsPTb.3045$...
    > Yeah, combing the tabstrip with the multipage gives you the behaviour your
    > trying to achieve with your custom control, however you've managed to get
    > your control working and resolved. Most times when you dig too deep only

    you
    > the author can come up with the solutions and someone else will only slow
    > you down. This is one of those cases ;P
    >
    > Glad you solved Jiho ;)
    > "Jiho Han" <> wrote in message
    > news:eql5%...
    > > Never mind, it does come with the source. I see that the tab

    > functionality
    > > is implemented as two separate controls a tabstrip and multipage, which

    is
    > > ok I guess but the multipage control doesn't support drag and drop of

    > other
    > > controls which is unfortunate...
    > >
    > > "Jiho Han" <> wrote in message
    > > news:...
    > > > Thanks for keeping up Alessandro.
    > > >
    > > > Really, sometimes solutions are in the simplest places you've never

    > > thought
    > > > to look because it's so simple.
    > > > What I ended up doing is that I went back to my original design where

    my
    > > > tabs are derived from Panel - it really doesn't matter if it is any

    > other
    > > > Control though - and created a custom collection editor and overrode

    the
    > > > method CreateInstance. In it I create a new instance of the tab panel

    > and
    > > > return it. This way there is no site for the control and it behaves
    > > > identically as when the control is parsed from HTML. I really didn't

    > want
    > > > those declaration statements in my codebehind for each tab anyway, so

    > it's
    > > > working out perfectly.
    > > >
    > > > BTW, do you know if they have sources available for those IE web

    > controls?
    > > > Probably not eh?
    > > > Thanks
    > > >
    > > > "Alessandro Zifiglio" <> wrote

    in
    > > > message news:KqNTb.2948$...
    > > > > Jiho, just a thought but if this is not working for you, and y our

    > > already
    > > > > going to make changes to your control, try looking at the source

    code
    > > > thats
    > > > > available with the IE web controls. Theres a TabStrip control in

    > there.
    > > > They
    > > > > are not using panels but I'm sure you could use some implementation
    > > > > techniques, ideas from them.
    > > > > "Jiho Han" <> wrote in message
    > > > > news:%...
    > > > > > Thanks Alessandro for your reponse.
    > > > > >
    > > > > > You're correct. I did set ToolBoxItem(false) but did not set
    > > > > > DesignTimeVisible(false) at the same time. However having done

    > that,
    > > it
    > > > > > didn't change the outcome.
    > > > > > Ok, this is what I am trying to do. I want to add my custom

    control
    > > to
    > > > > the
    > > > > > form, edit it, add to its collection either via designer or in

    HTML
    > > but
    > > > > have
    > > > > > it not write out the collection item (panel) declaration

    statements
    > in
    > > > my
    > > > > > codebehind.
    > > > > >
    > > > > > In pursuit of this functionality, I've tried to use

    > > ShouldCodeSerialize
    > > > > > method of the ControlDesigner class with no success. This stops

    it
    > > from
    > > > > > writing out to the codebehind but at the same time, it stops HTML
    > > > changes
    > > > > to
    > > > > > take effect. I tried to attach a derived CodeDomSerializer to the
    > > > control
    > > > > > with no success. It simply didn't seem to do anything.
    > > > > >
    > > > > > One thing I've noticed is that whenever I tried to add any control

    > > type
    > > > > > through the collection editor, it writes out the declaration

    > statments
    > > > to
    > > > > my
    > > > > > codebehind class. When I derived my custom panel from Panel or

    > > Control,
    > > > > the
    > > > > > statements were there. When I derived from nothing - thus

    object -
    > it
    > > > did
    > > > > > not. I don't think it's the work of CollectionEditor per se.

    I've
    > > > > digging
    > > > > > around for a bit, and it simply depends on the fact whether the
    > > > component
    > > > > > has a name or not. The name is not a property of the control but

    > > rather
    > > > > the
    > > > > > Site that is attached to a component by the designer. When the
    > > > collection
    > > > > > editor creates the component, it asks the VS to create it via
    > > > > > CreateComponent method while in HTML mode, it does not and so

    there
    > is
    > > > no
    > > > > > Site property available, thus no Name. When there is no Name for

    a
    > > > > > component, VS does not write out the statement to the codebehind I

    > > guess
    > > > > > because it doesn't know what to name it :).
    > > > > >
    > > > > > At this point, I am really confused as to what's really going on

    and
    > > am
    > > > > > losing patience. I just might change my Panel control so that it

    > does
    > > > not
    > > > > > derive from a Control. That way it won't automaticall be added.

    > And
    > > > I'll
    > > > > > just add the actual Panels in my CreateChildControls. I'll let

    you
    > > know
    > > > > how
    > > > > > that works out. This is only the beginning since after this, I am
    > > > trying
    > > > > to
    > > > > > attach ReadWriteControlDesigner to my control so that the page
    > > > developers
    > > > > > can drag and drop other controls onto it. As you may have guess

    I'm
    > > > > trying
    > > > > > to create a TabControl :) Page control uses

    > TemplatedControlDesigner
    > > > > > however and I am still wondering how these two are different and

    > which
    > > > one
    > > > > > to use ultimately.
    > > > > >
    > > > > > Thanks for reading. If any Microsoft guys are reading this, I'd

    > > really
    > > > > > appreciate some clarification.
    > > > > > Jiho
    > > > > >
    > > > > > "Alessandro Zifiglio" <>

    wrote
    > > in
    > > > > > message news:TgSSb.2008$...
    > > > > > >
    > > > > > > hi Jiho,
    > > > > > > do you see these unwanted child panels in your toolbox as well ?

    > > Which
    > > > > > ever
    > > > > > > the case I think your child panels are added in your code behind
    > > > because
    > > > > > > your collections derieve from panel which in turn is a

    webcontrol.
    > > > > > > Try specifying the following to your collection to hide it from

    > the
    > > > > > toolbox
    > > > > > > and designtime, not sure if this is your case, however give it a

    > > try.
    > > > I
    > > > > > have
    > > > > > > a hunch that you added the toolboxitem(false) attribute and

    forgot
    > > to
    > > > > set
    > > > > > > the DesignTimeVisible to false as well ;P
    > > > > > > [ToolboxItem(false),DesignTimeVisible(false)]
    > > > > > >
    > > > > > >
    > > > > > > "Jiho Han" <> wrote in message
    > > > > > > news:%...
    > > > > > > > I have a custom control - deriving from WebControl - that

    > contains
    > > a
    > > > > > > custom
    > > > > > > > collection property as the default property.
    > > > > > > > The collection implements IList and each item is also a custom
    > > > control
    > > > > > > > deriving from Panel control.
    > > > > > > > I don't have a custom collection editor.
    > > > > > > >
    > > > > > > > Whenever I add my item through the collection editor, the

    member
    > > > name
    > > > > > > > generated by it are "myPanel1", "myPanel2", and so on where

    the
    > > the
    > > > > > class
    > > > > > > > name is MyPanel. And that member name is then put in the

    > > codebehind
    > > > > > like
    > > > > > > > so:
    > > > > > > >
    > > > > > > > protected MyPanel myPanel1;
    > > > > > > > protected MyPanel myPanel2;
    > > > > > > >
    > > > > > > > Is there a way to override this behavior? Also, I figured

    > setting
    > > > the
    > > > > > ID
    > > > > > > > property on the item before it being added to the collection

    > might
    > > > do
    > > > > > the
    > > > > > > > trick but it didn't. So now I have in my codebehind

    > declarations
    > > > like
    > > > > > > above
    > > > > > > > but in my HTML the thing is persisted like:
    > > > > > > >
    > > > > > > > <cc:MyPanel Caption="MyPanel1" ID="MyPanel1"></cc:MyPanel>
    > > > > > > >
    > > > > > > > And c# complains because it's case-sensitive.
    > > > > > > >
    > > > > > > > Another thing that bothers me more is this -
    > > > > > > >
    > > > > > > > My main control is derived from WebControl so

    > ParseChildren(true)
    > > > and
    > > > > > > > PersistChildren(false) are the default. ParseChild(true,
    > > > "MyPanels")
    > > > > > > > actually since, I have the collection as the default property.
    > > > > > > >
    > > > > > > > So my code looks like this:
    > > > > > > >
    > > > > > > >
    > > > [DesignSerializationVisibility(DesignSerializationVisibility.Content),
    > > > > > > > PersistenceMode(PersistenceMode.InnerDefaultProperty),
    > > > > > > > NotifyParentProperty(true)]
    > > > > > > > public MyPanelCollection MyPanels
    > > > > > > > {
    > > > > > > > get
    > > > > > > > {
    > > > > > > > if (_myPanels == null)
    > > > > > > > _myPanels = new MyPanelCollection(this);
    > > > > > > > return _myPanels;
    > > > > > > > }
    > > > > > > > }
    > > > > > > >
    > > > > > > > It works. Maybe too well. Add 3 panels through the

    collection
    > > > > editor,
    > > > > > it
    > > > > > > > results in the following HTML.
    > > > > > > >
    > > > > > > > <cc:MyCustomControl ID="MyCustomControl1" runat="server">
    > > > > > > > <cc:MyPanel Caption="myPanel1"

    > ID="myPanel1"></cc:MyPanel>
    > > > > > > > <cc:MyPanel Caption="myPanel2"

    > ID="myPanel2"></cc:MyPanel>
    > > > > > > > <cc:MyPanel Caption="myPanel3"

    > ID="myPanel3"></cc:MyPanel>
    > > > > > > > </cc:MyCustomControl>
    > > > > > > >
    > > > > > > > That's fine, but at the same time, those 3 MyPanels are added

    as
    > > > child
    > > > > > > > controls to my MyCustomControl1 and three of those statements

    > get
    > > > put
    > > > > > into
    > > > > > > > my codebehind. I go to the HTML view, add a fourth MyPanel
    > > > following
    > > > > > all
    > > > > > > > conventions except for the number 4. I switch to the design

    > view,
    > > > > open
    > > > > > up
    > > > > > > > the collection editor and now all my members are listed as

    > > "TabPage"
    > > > > > which
    > > > > > > > of course do not match any of the statements in my codebehind.

    > > And
    > > > > > those
    > > > > > > > three statements are wiped out. I don't know if that's the

    > > reason.
    > > > > > What
    > > > > > > > gives?
    > > > > > > >
    > > > > > > > And I don't understand why my MyPanel controls are being added

    > as
    > > > > child
    > > > > > > > controls in the first place. I don't add them in my code -

    > > actually
    > > > I
    > > > > > was
    > > > > > > > but then I commented out CreateChildControls. Isn't
    > > > > ParseChildren(true)
    > > > > > > > supposed to parse the nested content as properties? And so it
    > > > > correctly
    > > > > > > > parses the default collection and adds individual MyPanel

    items
    > to
    > > > the
    > > > > > > > collection correctly, but why are they added to

    MyCustomControl
    > as
    > > > > child
    > > > > > > > controls? Did I confuse anyone or is it just me?
    > > > > > > >
    > > > > > > > Help.
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Alessandro Zifiglio, Feb 3, 2004
    #8
    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. Stylus Studio
    Replies:
    0
    Views:
    703
    Stylus Studio
    Aug 3, 2004
  2. Øyvind Isaksen
    Replies:
    1
    Views:
    988
    Øyvind Isaksen
    May 18, 2007
  3. John Saunders

    Collection Editor vs. Item ID

    John Saunders, Jul 19, 2003, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    233
    Yan-Hong Huang[MSFT]
    Jul 22, 2003
  4. Replies:
    1
    Views:
    298
    Tim Dot NoSpam
    May 19, 2006
  5. Sergio
    Replies:
    0
    Views:
    273
    Sergio
    May 29, 2006
Loading...

Share This Page