Hi Justin:
(PS: Have enjoyed reading your blog in the past :-) )
Thanks for the info on IDE lifespan. Pretty short!
I've been trying some wierd variations with the above info, out of perverse curiosity...
My latest dumb idea was to see what would happen if I made a control that has a sub-control as a property.
I'm talking about:
Calendar : WebControl {
public CalendarMonth Month {...}}
}
CalendarMonth : WebControl {
}
"Eh?!? Why?!?!" You ask... beats me :-) I just wanted to see...
Actually the reason was that I was wondering if I could use a 'dummy' object to store variables for a MonthView, and in Render, use the vars from the dummy to make a real one to Render.
This would save me time since I would not have to create a whole set of properties just to hold the same vars that i will later push to the child control...
In other words, I'm lazy.
In fact, in Render(), one can do:
Controls.Add (this.Month);
since its both a property accessible via a this. and a control derived from webcontrol...
Note: One of course has to attach ExpandableObject attr to CalendarMonth, first or you wont see it in the properties panel of the IDE.
Result? Madness
Well. Interesting behaviour happens. Not enough works to be useful...but It ALMOST works for the moment... I just can't decide yet if it has a chance of being useful, rather than just an excercise in pissing off the IDE. Things to think about and resolve:
a)
No Clone
The above works correctly for a single month view -- but fails to be useful/intuitive when dealing with a Year view:
for (int i=0;i<12;i++){Controls.Add(new Month.Clone());....
Except that there is no Clone method to get around using an instantiated control twice or more...
Have an ideas how one could do something like this?
b)
Who'se the Boss around here?!
Putting one control inside a second one confuses the IDE in terms of who is the boss control, and what is the outer tag. I've noticed that when I change a prop of the child control (CalendarMonth) it flips out at the serialization state and adds them as incorrectly xml'ed properties in the parent property!
c)
Need more insight in Site...
Oh. I nearly forgot....the reason I brought this all up is that I ran into something else that was wierd.
In a normal (or parent control) I can use:
if (this.Site) && (this.Site.DesignMode){try {this.Render(EventArgs.Empty);}catch{}}
to force a fake PreRender event. But guess what...in a child control, the Site object == null. Eh? Wierd behavior all around.
I know, I know:
Why do I do these things rather than leave them alone.......
....And what does one respond to a post from such an obviously insane person?
Sky
PS: This < code > tag is nice -- but way to much margin top and bottom.