I have one method as,
public function DoSomethingGenricWithUIControls(ByVal incomingData As Object)
//Fun Stuff
End Function
This method will be get called and can get passed the Page
,UserControl
, or any other type.
I want to check the type of incoming object, if it's Page
,UserControl
or other type.
But I was unable to do that. Whenever I tried using the GetType()
of typeOf()
on System.Web.UI.UserControl
. It gives,
'UserControl' is a type in 'UI' and cannot be used as an expression.
When I tried other methods like .IsAssignableFrom()
and .IsSubclassOf()
but I was still unable to do that.
One more note my incoming usercontrols
or page
can be multiple inherited from different controls/pages. So its immediate base type is not that of System.Web.UI.<Type>
.
Let me know in case of any confusion. VB/C# any way would work for me.
UPDATE
I have tried like,
if( ncomingPage.GetType() Is System.Web.UI.UserControl)
This gives me same issue as above,
'UserControl' is a type in 'UI' and cannot be used as an expression.