且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何访问内容页面中Master页面的控件

更新时间:2023-12-01 18:52:28

您需要@MasterPage指令..



像这样:
You need the @MasterPage Directive..

Like this:
<%@ MasterType virtualPath="~/MasterPage.master"%>





看看这个:以编程方式使用ASP.NET母版页 [ ^ ]


在您的内容页面中添加MasterPageFile =〜/ Masterpage.Master
by adding MasterPageFile="~/Masterpage.Master" in your content page


假设您要访问TextBox Maste r页面上的内容页面..可以像这样访问





Suppose you want to access the TextBox of Master page on the Content page..it can be access like this


TextBox txtBox = this.Master.Master.FindControl("txtMasterPageMaster") as TextBox;