D
Darren Clark
Is there any way to get the UserControl designer(or my own designer) to
create a class other than UserControl at design time? Or to find out what the
actual class of a UserControl is at design time?
Specifically the situation I have is this:
First the classes...
public abstract class A
{
}
public class B<T>: UserControl where T: A
{
}
public class C: A
{
}
public class D: B<C>
{
}
public class E: D
{
}
public class F: WebControl
{
[Editor(typeof(MyPropertyEditor),typeof(UITypeEditor))]
public string MyProperty;
}
Now....
I have a user control class E that inherits from D, which in turn inherits
from B<C>(my control could just as well inherit directly from B<C> but I
suspect that may make solving my problem even harder). At this point the
designer works and everything is happy. I drop a WebControl of type F onto my
user control. When the editor MyPropertyEditor is invoked, the statement
"context.NamingContainer.ToString()" returns "System.Web.UI.UserControl".
This indicates that at design time the container is a basic UserControl and
not class E, which is not surprising.
My problem is that in the disigner for F, I want to find out what C is. In
order to do this I need to know the true class of the UserControl descendent
that my WebControl was dropped on.
I added the generics in case that makes a difference, but I don't think it
does. The simple question is really "If I have an intermediate class between
UserControl and my actual control, how can I find out what that intermediate
class is at design time?"
Darren Clark
Lead Software Architect
Ecast, Inc.
http://www.ecastinc.com
create a class other than UserControl at design time? Or to find out what the
actual class of a UserControl is at design time?
Specifically the situation I have is this:
First the classes...
public abstract class A
{
}
public class B<T>: UserControl where T: A
{
}
public class C: A
{
}
public class D: B<C>
{
}
public class E: D
{
}
public class F: WebControl
{
[Editor(typeof(MyPropertyEditor),typeof(UITypeEditor))]
public string MyProperty;
}
Now....
I have a user control class E that inherits from D, which in turn inherits
from B<C>(my control could just as well inherit directly from B<C> but I
suspect that may make solving my problem even harder). At this point the
designer works and everything is happy. I drop a WebControl of type F onto my
user control. When the editor MyPropertyEditor is invoked, the statement
"context.NamingContainer.ToString()" returns "System.Web.UI.UserControl".
This indicates that at design time the container is a basic UserControl and
not class E, which is not surprising.
My problem is that in the disigner for F, I want to find out what C is. In
order to do this I need to know the true class of the UserControl descendent
that my WebControl was dropped on.
I added the generics in case that makes a difference, but I don't think it
does. The simple question is really "If I have an intermediate class between
UserControl and my actual control, how can I find out what that intermediate
class is at design time?"
Darren Clark
Lead Software Architect
Ecast, Inc.
http://www.ecastinc.com