You cannot access the Master page directly, you need to create a property of it, and use that to access the methods.(您不能直接访问母版页,需要创建它的属性,然后使用该属性来访问方法。)
Site1
is the class name of the Master page ( public partial class Site1 : System.Web.UI.MasterPage
)(Site1
是母版页的类名称( public partial class Site1 : System.Web.UI.MasterPage
))
public Site1 MyMaster;
protected void Page_Load(object sender, EventArgs e)
{
MyMaster = (Site1)Page.Master;
}
And then you have access in the aspx(然后您就可以访问aspx)
<%= MyMaster.RandomString() %>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…