zoukankan      html  css  js  c++  java
  • asp.net 动态加载的用户控件属性传id值问题

    页面部分代码:

    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; }
      }

  • 相关阅读:
    hdu 3613 Best Reward 扩展kmp
    hdu 4333 Revolving Digits 扩展kmp
    poj 1904 King's Quest 强连通
    hdu 3068 最长回文 manacher
    Codeforces Round #243 (Div. 2) C. Sereja and Swaps
    poj 3680 Intervals 费用流
    两个kmp hdu 2594 & hdu 2087
    hdu 3336 count the string
    Arcgis安装要素
    JS关闭窗口而不提示
  • 原文地址:https://www.cnblogs.com/hjtdlx/p/2226569.html
Copyright © 2011-2022 走看看