C# 用户控件、子母版页和父母版页(如何从用户控件调用函数)
基本上我有一个userControl.ascx和很多代码。。。此用户控件在Child.MasterPage中使用,Child.MasterPage继承自Parent.MasterPage 在Parent.MasterPage中,.cs文件中有一个方法,该方法接受字符串并将其传递给文本 问题是: 我花了几个小时试图将字符串从UserControl直接传递到Parent.MasterPage.cs方法,但没有成功。child.MasterPage没有c#文件,它只是从parent.master继承的 我使用的一行代码可以将值传递给patent.MasterPage,其内容如下。。但我无法通过的方法请帮助C# 用户控件、子母版页和父母版页(如何从用户控件调用函数),c#,asp.net,C#,Asp.net,基本上我有一个userControl.ascx和很多代码。。。此用户控件在Child.MasterPage中使用,Child.MasterPage继承自Parent.MasterPage 在Parent.MasterPage中,.cs文件中有一个方法,该方法接受字符串并将其传递给文本 问题是: 我花了几个小时试图将字符串从UserControl直接传递到Parent.MasterPage.cs方法,但没有成功。child.MasterPage没有c#文件,它只是从parent.master继承的
MasterPage myMasterPage = this.Parent.Parent.Page.Master.Master;.
尝试像((ParentMaster)this.parent.parent).SomeMethod()那样键入它。尝试像((ParentMaster)this.parent.parent.SomeMethod()那样键入它当然,如果你想修改你的用户界面,你可能不得不到处修改这一行。当然,如果你想修改你的用户界面,你可能不得不到处修改这一行