K
Ken Dopierala Jr.
Hi,
In VS.Net in Design Mode when I add a bunch of the same custom control to my
page VS.Net assigns unique IDs for the parent control (i.e. MyCalendar) but
seems to lose track and assign the same IDs to child controls causing it to
say that more than one control on the page is named the same. For example:
<cc:MyCalendar id="MyCalendar1" ...>
<MyWeek id="MyWeek1" ...>
</MyWeek>
<MyWeek id="MyWeek2" ...>
</MyWeek>
<MyWeek id="MyWeek3" ...>
</MyWeek>
</cc:MyCalendar>
<cc:MyCalendar id="MyCalendar2" ...>
<MyWeek id="MyWeek4" ...>
</MyWeek>
<MyWeek id="MyWeek5" ...>
</MyWeek>
<MyWeek id="MyWeek6" ...>
</MyWeek>
</cc:MyCalendar>
<cc:MyCalendar id="MyCalendar3" ...>
<MyWeek id="MyWeek2" ...>
</MyWeek>
<MyWeek id="MyWeek3" ...>
</MyWeek>
<MyWeek id="MyWeek7" ...>
</MyWeek>
</cc:MyCalendar>
In the above all parent controls are unique but for some reason when the 3rd
MyCalendar control is placed on the page and then MyWeeks are added through
the Property Window via a collection dialog the MyWeek IDs suddenly start to
repeat. I have tried it both with INamingContainer implemented and without.
Is there a way I can programatically set the ID of the MyWeek child controls
before VS.Net assigns one? If so, what event? I can't seem to find a place
to break to find out where this is happening. After it happens it is too
late because I do not want to force control of these IDs, so I won't know if
the ID is VS.Net created or developer assigned after the initial creation.
My goal is to always have a unique ID for every child control added and I
can do that if I know where capture where the ID is first assigned.
I'm coding everything in VB.Net but feel free to respond in C# or whatever
you want. Thanks! Ken.
P.S. My next step once this is solved is creating a custom UITypeEditor
instead of relying on the default collection interface in the properties
window. If there is a way I can pass in the ID of the parent
("MyCalendar3"), which VS.Net is always making unique, then I can prefix
that to the child there and guarantee uniqueness. Can I pass that in? If
so, how do I do that? Then I won't even need an answer to my main post.
Thanks!
In VS.Net in Design Mode when I add a bunch of the same custom control to my
page VS.Net assigns unique IDs for the parent control (i.e. MyCalendar) but
seems to lose track and assign the same IDs to child controls causing it to
say that more than one control on the page is named the same. For example:
<cc:MyCalendar id="MyCalendar1" ...>
<MyWeek id="MyWeek1" ...>
</MyWeek>
<MyWeek id="MyWeek2" ...>
</MyWeek>
<MyWeek id="MyWeek3" ...>
</MyWeek>
</cc:MyCalendar>
<cc:MyCalendar id="MyCalendar2" ...>
<MyWeek id="MyWeek4" ...>
</MyWeek>
<MyWeek id="MyWeek5" ...>
</MyWeek>
<MyWeek id="MyWeek6" ...>
</MyWeek>
</cc:MyCalendar>
<cc:MyCalendar id="MyCalendar3" ...>
<MyWeek id="MyWeek2" ...>
</MyWeek>
<MyWeek id="MyWeek3" ...>
</MyWeek>
<MyWeek id="MyWeek7" ...>
</MyWeek>
</cc:MyCalendar>
In the above all parent controls are unique but for some reason when the 3rd
MyCalendar control is placed on the page and then MyWeeks are added through
the Property Window via a collection dialog the MyWeek IDs suddenly start to
repeat. I have tried it both with INamingContainer implemented and without.
Is there a way I can programatically set the ID of the MyWeek child controls
before VS.Net assigns one? If so, what event? I can't seem to find a place
to break to find out where this is happening. After it happens it is too
late because I do not want to force control of these IDs, so I won't know if
the ID is VS.Net created or developer assigned after the initial creation.
My goal is to always have a unique ID for every child control added and I
can do that if I know where capture where the ID is first assigned.
I'm coding everything in VB.Net but feel free to respond in C# or whatever
you want. Thanks! Ken.
P.S. My next step once this is solved is creating a custom UITypeEditor
instead of relying on the default collection interface in the properties
window. If there is a way I can pass in the ID of the parent
("MyCalendar3"), which VS.Net is always making unique, then I can prefix
that to the child there and guarantee uniqueness. Can I pass that in? If
so, how do I do that? Then I won't even need an answer to my main post.
Thanks!