如何从母版页到内容页调用方法 [英] How to call the method from master page to content page
本文介绍了如何从母版页到内容页调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在母版页中编写了一个方法..现在我要在内容页中调用该方法..我该怎么做?
在此先感谢
Hi ,
I have written one method in the master page.. now i want call that method in the content page .. how can i do this ??
thanks in advance
推荐答案
要从内容页面的母版页访问方法,请确保首先将母版页中的方法声明为public
而不是从您的内容页面代码后面调用此代码:
To access a method from master page in the content page ensure first The method in master page is declared as public
than call this code from your content page code behind:
MasterPageClassName MyMasterPage = (MasterPageClassName)Page.Master;
MyMasterPage.SetMenuToRegistered();
其中:SetMenuToRegistered()-是定位在母版页类中的方法.
where: SetMenuToRegistered() - is a method positioned in the master page class.
包含:
<%@ MasterType virtualpath="~/Masters/Master1.master" %>
在子页面中,其中〜/Masters/Master1.master"是母版页的路径
然后,它可以通过Master.xxx
in the child page, where "~/Masters/Master1.master" is the path to the master page
It can then access any public members via Master.xxx
这篇关于如何从母版页到内容页调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文