Thanks for replies,
I can't use typeof(Class1) or something similar,
because I don't know the string, and "Class1" is just an example.
I'll explain more,
There are lots of classes in business layer, they behave same and are
inherited from one base class.
There is a WebForm that users load it through menus, and the
classname given in QueryString.
Now we have something like it in the WebForm:
BaseClass baseclass;
string q=Request.QueryString["classname"];
switch (q)
{
case "ClassX":
BaseClass=new ClassX();break;
case "ClassY":
BaseClass=new ClassY();break;
case "ClassZ":
BaseClass=new ClassZ();break;
}
grid.DataSource=BaseClass().GetBrowsableData();
I want to get rid of this switch case statement, because the programmers
in our team want to add many classes.
In this situation, for each class they've to add a switch case and checkouts
and checkins and waitings!
So, it seems there is "no" way to do that in a WebSite. Right?
"Milosz Skalecki [MCAD]" <mi*****@REMOVEITwp.plwrote in message
news:66**********************************@microsof t.com...
Howdy,
Static method GetType(String) works on assemblies loaded from disk. MSFT
say "If you call GetType(String) to look up a type defined in a dynamic
assembly defined using the System.Reflection.Emit services, you might get
inconsistent behavior. The behavior depends on whether the dynamic
assembly
is persistent, that is, created using the RunAndSave or Save access"
instead use
typeof(Class1)
or
InstanceOfClass1.GetType()
hope this helps
--
Milosz
"Saber" wrote:
>In an ASP.Net Website I've a string and want to convert that to Type.
Let's consider the string "Class1"
I tried: Type t = Type.GetType("Class1");
but it returns null.