Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > changing the default caption/id for an item in a collection editor?

Reply
Thread Tools

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

 
 
Jiho Han
Guest
Posts: n/a
 
      01-30-2004
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(DesignSerializationV isibility.Content),
PersistenceMode(PersistenceMode.InnerDefaultProper ty),
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.


 
Reply With Quote
 
 
 
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      01-31-2004

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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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(DesignSerializationV isibility.Content),
> PersistenceMode(PersistenceMode.InnerDefaultProper ty),
> 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.
>
>



 
Reply With Quote
 
 
 
 
Jiho Han
Guest
Posts: n/a
 
      02-02-2004
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" <(E-Mail Removed)> wrote in
message news:TgSSb.2008$(E-Mail Removed)...
>
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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(DesignSerializationV isibility.Content),
> > PersistenceMode(PersistenceMode.InnerDefaultProper ty),
> > 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.
> >
> >

>
>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      02-03-2004
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in
> message news:TgSSb.2008$(E-Mail Removed)...
> >
> > 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" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > 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(DesignSerializationV isibility.Content),
> > > PersistenceMode(PersistenceMode.InnerDefaultProper ty),
> > > 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.
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Jiho Han
Guest
Posts: n/a
 
      02-03-2004
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" <(E-Mail Removed)> wrote in
message news:KqNTb.2948$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in
> > message news:TgSSb.2008$(E-Mail Removed)...
> > >
> > > 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" <(E-Mail Removed)> wrote in message
> > > news:%(E-Mail Removed)...
> > > > 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(DesignSerializationV isibility.Content),
> > > > PersistenceMode(PersistenceMode.InnerDefaultProper ty),
> > > > 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.
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Jiho Han
Guest
Posts: n/a
 
      02-03-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in
> message news:KqNTb.2948$(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote

in
> > > message news:TgSSb.2008$(E-Mail Removed)...
> > > >
> > > > 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" <(E-Mail Removed)> wrote in message
> > > > news:%(E-Mail Removed)...
> > > > > 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(DesignSerializationV isibility.Content),
> > > > > PersistenceMode(PersistenceMode.InnerDefaultProper ty),
> > > > > 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.
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      02-03-2004
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" <(E-Mail Removed)> wrote in message
news:eql5%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in
> > message news:KqNTb.2948$(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote in message
> > > news:%(E-Mail Removed)...
> > > > 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" <(E-Mail Removed)> wrote

> in
> > > > message news:TgSSb.2008$(E-Mail Removed)...
> > > > >
> > > > > 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" <(E-Mail Removed)> wrote in message
> > > > > news:%(E-Mail Removed)...
> > > > > > 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(DesignSerializationV isibility.Content),
> > > > > > PersistenceMode(PersistenceMode.InnerDefaultProper ty),
> > > > > > 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.
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      02-03-2004
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/de...gnersample.asp


"Alessandro Zifiglio" <(E-Mail Removed)> wrote in
message news:zsPTb.3045$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:eql5%(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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" <(E-Mail Removed)> wrote

in
> > > message news:KqNTb.2948$(E-Mail Removed)...
> > > > 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" <(E-Mail Removed)> wrote in message
> > > > news:%(E-Mail Removed)...
> > > > > 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" <(E-Mail Removed)>

wrote
> > in
> > > > > message news:TgSSb.2008$(E-Mail Removed)...
> > > > > >
> > > > > > 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" <(E-Mail Removed)> wrote in message
> > > > > > news:%(E-Mail Removed)...
> > > > > > > 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(DesignSerializationV isibility.Content),
> > > > > > > PersistenceMode(PersistenceMode.InnerDefaultProper ty),
> > > > > > > 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.
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Řyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
WebControl - CollectionEditor Problem. Changing id property of new added collection item causes not adding item to collection - Sergio ASP .Net Web Controls 0 05-29-2006 06:20 AM
XHTML block item inside and inline item tj.tzavaras@gmail.com HTML 2 04-28-2005 03:42 PM
Display Related Item or Add Item ssoss ASP .Net 2 09-18-2003 11:35 PM
item[LENGTH] vs. *item and malloc() root C Programming 2 08-21-2003 07:07 PM



Advertisments