asp.net 动态加载的用户控件属性传id值问题
2011-07-27 11:26
796 查看
页面部分代码:
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; }
}
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; }
}
相关文章推荐
- asp.net 动态加载的用户控件属性传id值问题
- asp.net定义用户控件时,属性持久化和如何动态加载的问题
- Asp.net 2.0 动态加载其他子目录用户控件问题
- Asp.net开发心得点滴[动态加载的用户控件使用事件委托,交给页面处理的事件无效问题]
- Asp.net 2.0 动态加载其他子目录用户控件问题
- ASP.NET动态加载用户控件的页面生成过程
- ASP.NET动态加载用户控件的页面生成过程
- 在ASP.NET中动态加载内容(用户控件和模板)
- ASP.net中动态加载控件时一些问题的总结
- Asp.net动态加载用户自定义控件,并转换成HTML代码
- ASP.net中动态加载用户控件
- asp.net后台动态加载用户控件
- Asp.net动态加载用户自定义控件,并转换成HTML代码
- asp.net中动态加载用户控件的办法
- ASP.net中的AJAX:动态加载用户控件(Calendar控件为例)
- asp.net动态加载ascx用户控件
- asp.net动态加载用户控件,关于后台添加、修改的思考
- ASP.NET动态加载用户控件的页面生成过程
- ASP.NET动态加载用户控件的页面生成过程
- asp.net 动态加载用户控件