用户控件,儿童母版页和父母版页(如何调用函数形式的用户控制) [英] UserControl, Child Master Page and Parent Master Page (How to call function form User Control)

查看:82
本文介绍了用户控件,儿童母版页和父母版页(如何调用函数形式的用户控制)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我有很多code的userControl.ascx ......这用户控件在Child.MasterPage使用和Child.MasterPage从Parent.MasterPage继承。

在Parent.MasterPage我在cs文件的方法,此方法接受一个字符串,并将其传递到文字。

问题:

我已经花了几个小时试图从我的用户直接传递一个字符串Parent.MasterPage.cs方法,没有运气。该child.MasterPage没有一个C#文件,它只是从parent.master继承

code的一条线,我使用,这样我可以传递值到patent.MasterPage读这样的..但我不能够传递给方法,请大家帮忙!

 母版myMasterPage = this.Parent.Parent.Page.Master.Master ;.


解决方案

尝试类型转换它像((ParentMaster)this.parent.parent).SomeMethod()

Basically I have a userControl.ascx with a lot of code... this user control is used in the Child.MasterPage and the Child.MasterPage inherits from a Parent.MasterPage.

In the Parent.MasterPage I have a method in the .cs file, this method accepts a string and passes it to a literal.

The problem:

I have spent hours trying to pass a string from my UserControl directly to the Parent.MasterPage.cs method with no luck. The child.MasterPage does not have a c# file, it just inherits from the parent.master

a line of code that I am using so that I can pass values to the patent.MasterPage reads like this.. but I am not able to pass to the method please help!

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

解决方案

Try typecasting it like ((ParentMaster)this.parent.parent).SomeMethod()

这篇关于用户控件,儿童母版页和父母版页(如何调用函数形式的用户控制)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆