first, the Attributes class creates a new subclass, DetailattributesView CodeSecond, add attributes to the property declaration of the class
Public classtestattributes{[Detail (Attrname="width", Html ="<input type= ' text '/>", DefaultValue =" -", DataSource =NULL)] Public stringUsername {Get;Set;} Public classFactorydetail {[Detail (Attrname="width", Html ="<input type= ' text '/>", DefaultValue =" -", DataSource =NULL)] Public stringWidth {Set;Get; } [Detail (Attrname="Height", Html ="<input type= ' text '/>", DefaultValue =" -", DataSource =NULL)] Public stringHeight {Set;Get; } [Detail (Attrname="Status", Html ="<select></select>", DefaultValue =NULL, DataSource ="Select Text,value from Status")] Public stringStatus {Set;Get; } [Detail (Attrname="Tag Value", Html ="<input type= ' text '/>", DefaultValue ="", DataSource =NULL)] Public stringTag {Set;Get; } [Detail (Attrname="Description", Html ="<input type= ' text '/>", DefaultValue ="", DataSource =NULL)] Public stringDesc {Set;Get; } Public stringTest () {strings =""; Type Otype= This. GetType (); foreach(PropertyInfo OPIinchotype.getproperties ()) { Object[] Peratt = OPI. GetCustomAttributes (true); foreach(varTmpinchPeratt) { if(TMP. GetType () = =typeof(Factorydetail)) {Detailattribute Detailatt=(Detailattribute) tmp; S+="Attrname:"+ Detailatt.attrname +" "; } } } returns; } }}
C # features attributes and reflection