在母版页面内的页面后面的代码中获取fileupload id

时间:2009-12-07 15:16:08

标签: asp.net

我想知道当整个内容在contentplaceholder1.i中时我如何访问fileupload控件id尝试使用FindControlRecursive(控制根,字符串Id)方法,我已经调用它像FindControlRecursive(contentplaceholder1,fileupload1)但它不是working.so plz给出一些想法如何找到fileupload1 id

1 个答案:

答案 0 :(得分:1)

您可以使用MasterPage控件的FindControl方法在FileUpload页面中查找Content控件。

protected void Page_Load(object sender, System.EventArgs e)
{
    ContentPlaceHolder content = Page.Master.FindControl("ContentPlaceHolder1") as ContentPlaceHolder;    
    FileUpload fu = content.FindControl("FileUpload1") as FileUpload;
    //...
}