详细内容
内容页里访问模板里控件
发布日期:2011-07-18     点击:2673     字体:[ ]

在内容页里访问模板页控件,可用FindControl方法,例如:

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.Title = ConfigurationManager.AppSettings["comName"].ToString();
                Master.FindControl("pMenu").ID = "index";

                bindData();
            }
        }

判断控件是否存在可有效降低程序异常,例如:

if(Master.FindControl("pMenu") != null)

{

Master.FindControl("pMenu").ID = "index";

}

用户评论
昵称 
内容  *
验证码   
   
Copyright © 2010 zdbase.com All Rights Reserved. 苏ICP备15039389号 可人软件设计