[英]C# 3.5 : How do I get the name of the parent class from a UserControl?
C#3.5:如何從UserControl中動態獲取父類的名稱?
例如,
如果TestPage.aspx包含UserControl ucTestUc ,
我需要知道父類是TestPage。
我嘗試過:從ucTestUc中 ,
this.Parent.NamingContainer是ASP.testpage_aspx。
哪個很近,但沒有雪茄。
我可以擺脫前綴和后綴,但我無法恢復大寫。
?
string typeName = this.Page.GetType().Name;
string baseTypeName = this.Page.GetType().BaseType.Name;
string fileName = Path.GetFileName(Request.PhysicalPath);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.