随笔 - 121  文章 - 1 评论 - 21 trackbacks - 3

在.net 2.0 中如果使用了masterPage,则不能像以前那样使用 FindControl,则需要使用如下方法

先找到ContentPlaceHolder,然后再找在这个ContentPlaceHolder中的你要找的控件


1
2//MasterPage 中的ContentPlaceHolder ID
3string masterPageContentPlaceHolderID = "";
4//在 masterPageContentPlaceHolderID 中所要找到的控件的 ID
5string m_strSetDataToID = "";
6//例如找 TextBox
7TextBox textBoxFind = (TextBox)this.Page.Master.FindControl(masterPageContentPlaceHolderID).FindControl(m_strSetDataToID);
posted on 2006-11-09 18:56 foward.molly.宝儿 阅读(1040) 评论(1)  编辑 收藏