通过 原数据可以访问,我是访问后,才发现自己怎么都操作私有字段了呢
参考代码
public class l3data : system.componentmodel.component { private system.componentmodel.container components = null; private page _page; private arraylist literallist = new arraylist(); public l3data(system.componentmodel.icontainer container) { container.add(this); initializecomponent(); }
public l3data() { initializecomponent(); } protected override void dispose( bool disposing ) { if( disposing ) { if(components != null) { components.dispose(); } } base.dispose( disposing ); } #region 组件设计器生成的代码 private void initializecomponent() { components = new system.componentmodel.container(); } #endregion #region property public page page { get{return this._page;} set { this._page = value; type type = _page.gettype(); type = type.basetype; system.web.ui.webcontrols.literal literal = new literal(); system.reflection.fieldinfo[] fields = type.getfields(bindingflags.nonpublic|(bindingflags.static | bindingflags.instance)); foreach(system.reflection.fieldinfo field in fields) { if(field.fieldtype.equals(literal.gettype())) this.literallist.add(field); } int count =0; foreach(fieldinfo field in this.literallist) { count++; object obj = field.getvalue(this.page); literal = (literal)obj; if(literal.text.equals(“wx”)) literal.text =”i can see you”; else { literal.text=”wangxing”+count.tostring(); } } } } #endregion }.