Page code:
Arraylist url = new arraylist (); // module path
Arraylist MD = new arraylist (); // module ID
Url = jyoauser. return_rolemodel (role_id, system_id); // return the URL of the module corresponding to the role
MD = jyoauser. return_rolemodel2 (role_id, system_id); // return the ID of the module corresponding to the role
For (INT u = 0; U <URL. Count; U ++)
{
Control UC = new control ();
UC = page. loadcontrol (URL [u]. tostring ());
Type ptype = UC. GetType (); // automatically obtains the type of the control to be loaded.
Propertyinfo Pi = ptype. getproperty ("modelid"); // automatically obtain the property of the loaded control. Of course, if the method is ptype. getmethod
Pi. setvalue (UC, MD [u]. tostring (), null); // pass the module id value of the control to the modelid attribute of the control.
Test. Controls. Add (UC );
}
Controls for each presentation module are dynamically loaded from the database
Some code of a control:
Private int _ modelid; Module ID of the control
Public int modelid
{
Get {return this. _ modelid ;}
Set {This. _ modelid = value ;}
}