So I have tried GetType() but for some reason, It does include the namespace…
Does C# not have a property for a class specifying its name?
For example:
public class Parent : System.Web.UI.UserControl {
public someFunction(){
Child child = new Child();
Console.WriteLine(child.ThePropertyThatContainsTheName);
}
}
public class Child : Parent {
}
I have tried to create the Child with a string property that has the name hard-coded, but only if we could find a better workaround to this… maybe reflection or expressions…
Thanks in advance =)
Edit: I am working on user controls by the way…
If you are using an ASP.NET Web Application project, you will normally be using the code-behind model.
ASP.NET will dynamically generate and compile a class from your aspx/ascx file, which uses the class you defined in your code-behind file as a base class.
this.GetType().Nameandthis.GetType().FullNamewill return the name of the auto-generated class generated by ASP.NET. This auto-generated class will subclass the UserControl/WebPage class you have defined in your code-behind file (Inheritskeyword in the<%@Control ...>tag of your ascx file /<%@Page ...>tag of your aspx file).If you want the name of your code-behind class, use:
this.GetType().BaseType.Nameorthis.GetType().BaseType.FullName