找到一个母版页页上的控件 [英] Find a control on a page with a master page
本文介绍了找到一个母版页页上的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须找到一个控制
绑定到一个母版页的aspx页面。
I have to find a Control
in an aspx page bound to a master page.
主网页包含:
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
内容页面包含:
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
</asp:Content>
我添加了一个表
与 ID
formtable
作为的子内容2
。
我试着用下面的code访问表
,而code返回空
:
I tried to use the following code to access the Table
, but the code returns null
:
protected void Ok_Click(object sender, EventArgs e)
{
Table tblForm = this.FindControl("MainContent").FindControl("formtable") as Table;
}
我如何访问表
?
推荐答案
试试这个
Table tblForm = this.Master.FindControl("MainContent").FindControl("formtable") as Table;
此结账控件ID在内容页中命名更多详情
这篇关于找到一个母版页页上的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文