it技术博客

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
页面部分代码:

ArrayList url = new ArrayList();   // 模块路径
 ArrayList md=new ArrayList();   //模块id


        url = jyoauser.return_rolemodel(role_id, system_id);//返回角色对应模块url
        md = jyoauser.return_rolemodel2(role_id,system_id);//返回角色对应模块id

 

        for (int u = 0; u < url.Count; u++)
        {

 Control uc = new Control();
  uc = Page.LoadControl(url[u].ToString());
        

       

            Type pType = uc.GetType();//自动获得加载控件的类型
          
      PropertyInfo pi=pType.GetProperty("modelid"); //自动获得加载控件的属性 当然这里如果是方法用pType.GetMethod

      pi.SetValue(uc, md[u].ToString(), null); //把控件的模块id值传给控件的modelid属性


    
            test.Controls.Add(uc);
         
        }

每个表示模块的控件是从数据库动态加载
一个控件部分代码:
  private int _modelid;控件的模块id
  public int modelid
  {
  get { return this._modelid; }
  set { this._modelid = value; }
  }

posted on 2011-10-27 14:56  ie技术博客  阅读(1166)  评论(0编辑  收藏  举报