Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用户控件、子母版页和父母版页(如何从用户控件调用函数)_C#_Asp.net - Fatal编程技术网

C# 用户控件、子母版页和父母版页(如何从用户控件调用函数)

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继承的

基本上我有一个userControl.ascx和很多代码。。。此用户控件在Child.MasterPage中使用,Child.MasterPage继承自Parent.MasterPage

在Parent.MasterPage中,.cs文件中有一个方法,该方法接受字符串并将其传递给文本

问题是:

我花了几个小时试图将字符串从UserControl直接传递到Parent.MasterPage.cs方法,但没有成功。child.MasterPage没有c#文件,它只是从parent.master继承的

我使用的一行代码可以将值传递给patent.MasterPage,其内容如下。。但我无法通过的方法请帮助

MasterPage myMasterPage = this.Parent.Parent.Page.Master.Master;.

尝试像((ParentMaster)this.parent.parent).SomeMethod()那样键入它。

尝试像((ParentMaster)this.parent.parent.SomeMethod()那样键入它

当然,如果你想修改你的用户界面,你可能不得不到处修改这一行。当然,如果你想修改你的用户界面,你可能不得不到处修改这一行