Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to check existence of control?
Message
From
24/12/2006 20:18:10
 
 
To
24/12/2006 19:40:43
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01180075
Message ID:
01180077
Views:
17
You could try to instantiate the class with reflection ... it won't crash if it doesn't exist, it will just return a null:
string DLLName = "MyDLL.dll";
string ClassName = "MyDll.MyClass";
System.Reflection.Assembly oDLL;
object oClass;

// This "loads" the .DLL
oDLL = System.Reflection.Assembly.LoadFrom(DLLName);

// This creates the class instance
oClass = oDLL.CreateInstance(ClassName);

if (oClass != null)
{
    // the class exists
}
~~Bonnie



>Hi,
>I have code to add control to form dynamically during runtime. Before that, how could I check whether the particular control is already exist or not?
>
>Thank you
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform