C # 3.5: How to get parent class name from UserControl?

C # 3.5: How to get the dynamic name of the parent class from UserControl?

For instance,

If TestPage.aspx contains a UserControl ucTestUc ,

I need to know that the parent class is TestPage.

I tried: from ucTestUc ,

this.Parent.NamingContainer - ASP.testpage_aspx.

Which is close but no cigar.

I could get rid of the prefix and postfix, but I have no way to restore capitalization.

?

+3
source share
1 answer
string typeName = this.Page.GetType().Name;

string baseTypeName = this.Page.GetType().BaseType.Name;

string fileName = Path.GetFileName(Request.PhysicalPath);
+6
source

Source: https://habr.com/ru/post/1752673/


All Articles