Asp.Net usercontrol codebehind: reference nested class from another usercontrol
Edit: apparently it was a hickup in VS intellisense. Costed me quite some time, sight. Thanks for the help anyway.
What I'm trying to do is to reference开发者_StackOverflow中文版 an inner class from one codebehind to the other, I've managed to be able to reference the outer class using @ reference
and classname
. However I can't access the inner class. So to be more precise:
public partial class A : System.Web.UI.UserControl
{
public class Inner
{
}
}
And now in another .ascx(.cs) file:
public partial class B : System.Web.UI.UserControl
{
somemethod()
{
//reference A.Inner...how?
}
}
The reason for using the innerclass is that I'm bound to a framework, and can't add other things then the two .aspx controls.
To create the inner class, just do:
var inner = new A.Inner();
If A
is in a different namespace, then
var inner = new OtherNamespace.A.Inner();
Apparently it was a hickup in VS intellisense. Costed me quite some time, sight. Thanks for the help anyway.
精彩评论