Get original class name of default_aspx_modules_admin_useredit like name
-
Hi, If I do "this.GetType()" in an ascx.cs usercontrol, I get a strange name, which is the auto generated final class, in Web Site Project. e.g. default_aspx_modules_admin_useredit Is there a way to get the real class name, as I wrote the class? public class UserEdit I have some data assigned to controls in XML files, and controls would need to know their own name to access their own data. If possible, I don't want to create a readonly variable with the class name. protected readonly string OwnName = "UserEdit"; :-) Parse from AppVirtualPath? Any better ideas? Many thanks, Ferenc
-
Hi, If I do "this.GetType()" in an ascx.cs usercontrol, I get a strange name, which is the auto generated final class, in Web Site Project. e.g. default_aspx_modules_admin_useredit Is there a way to get the real class name, as I wrote the class? public class UserEdit I have some data assigned to controls in XML files, and controls would need to know their own name to access their own data. If possible, I don't want to create a readonly variable with the class name. protected readonly string OwnName = "UserEdit"; :-) Parse from AppVirtualPath? Any better ideas? Many thanks, Ferenc
-
Hi, If I do "this.GetType()" in an ascx.cs usercontrol, I get a strange name, which is the auto generated final class, in Web Site Project. e.g. default_aspx_modules_admin_useredit Is there a way to get the real class name, as I wrote the class? public class UserEdit I have some data assigned to controls in XML files, and controls would need to know their own name to access their own data. If possible, I don't want to create a readonly variable with the class name. protected readonly string OwnName = "UserEdit"; :-) Parse from AppVirtualPath? Any better ideas? Many thanks, Ferenc
Have you tried getting the type of the type? eg.:
Type parentClass = this.GetType().GetType();
-
Hi, Use
this.GetType().BaseType.Name
to get the class name orthis.GetType().BaseType.FullName
for the namespace heierarchy + class name.Clean code is the key to happiness.
Thank you, this one works well!
-
Have you tried getting the type of the type? eg.:
Type parentClass = this.GetType().GetType();
Hi, yes, thanks for comment. That returned "System.RuntimeType" Type in my ascx.cs class.