[Controlbuilder (typeof (textboxcontrolbuilder), defaultproperty ("text"), parsechildren (false), databindinghandler ("system. web. UI. design. textdatabindinghandler, system. design, version = 1.0.5000.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a "), validationproperty (" text "), defaultevent (" textchanged "), permissionset (securityaction. linkdemand, xml = "<permissionset class = \" system. security. permissionset \ "\ r \ n version = \" 1 \ "> \ r \ n <ipermission class = \" system. web. aspnethostingpermission, system, version = 1.0.5000.0, culture = neutral, publickeytoken = b77a5c561934e089 \ "\ r \ n version = \" 1 \ "\ r \ n Level = \" minimal \ "/> \ r \ n </permissionset> \ r \ N "), permissionset (securityaction. inheritancedemand, xml = "<permissionset class = \" system. security. permissionset \ "\ r \ n version = \" 1 \ "> \ r \ n <ipermission class = \" system. web. aspnethostingpermission, system, version = 1.0.5000.0, culture = neutral, publickeytoken = b77a5c561934e089 \ "\ r \ n version = \" 1 \ "\ r \ n Level = \" minimal \ "/> \ r \ n </permissionset> \ r \ N ")] public class textbox: webcontrol, ipostbackdatahandler
{
// Fields
Private Static readonly object eventtextchanged;
// Events
[Webcategory ("action"), websysdescription ("textbox_ontextchanged")]
Public event eventhandler textchanged;
// Methods
Static Textbox ();
Public Textbox ();
Protected override void addattributestorender (htmltextwriter writer );
Protected override void addparsedsubobject (Object OBJ );
Protected override void onprerender (eventargs E );
Protected virtual void ontextchanged (eventargs E );
Protected override void render (htmltextwriter writer );
Bool ipostbackdatahandler. loadpostdata (string postdatakey, namevaluecollection postcollection );
Void ipostbackdatahandler. raisepostdatachangedevent ();
// Properties
[Webcategory ("behavior"), websysdescription ("textbox_autopostback"), defaultvalue (false)]
Public Virtual bool autopostback {Get; set ;}
[Defaultvalue (0), websysdescription ("textbox_columns"), Bindable (true), webcategory ("appearance")]
Public Virtual int columns {Get; set ;}
[Bindable (true), webcategory ("behavior"), defaultvalue (0), websysdescription ("textbox_maxlength")]
Public Virtual int maxlength {Get; set ;}
[Webcategory ("behavior"), Bindable (true), defaultvalue (false), websysdescription ("textbox_readonly")]
Public Virtual bool readonly {Get; set ;}
[Bindable (true), webcategory ("behavior"), defaultvalue (0), websysdescription ("textbox_rows")]
Public Virtual int rows {Get; set ;}
Private bool savetextviewstate {Get ;}
Protected override htmltextwritertag tagkey {Get ;}
[Bindable (true), webcategory ("appearance"), defaultvalue (""), websysdescription ("textbox_text"), persistencemode (persistencemode. encodedinnerdefadefaproperty)]
Public Virtual string text {Get; set ;}
[Defaultvalue (0), websysdescription ("textbox_textmode"), webcategory ("behavior")]
Public Virtual textboxmode textmode {Get; set ;}
[Webcategory ("layout"), defaultvalue (true), websysdescription ("textbox_wrap")]
Public Virtual bool wrap {Get; set ;}
}
[Controlbuilder (typeof (textboxcontrolbuilder), defaultproperty ("text"), parsechildren (false), databindinghandler ("system. web. UI. design. textdatabindinghandler, system. design, version = 1.0.5000.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a "), validationproperty (" text "), defaultevent (" textchanged "), permissionset (securityaction. linkdemand, xml = "<permissionset class = \" system. security. permissionset \ "\ r \ n version = \" 1 \ "> \ r \ n <ipermission class = \" system. web. aspnethostingpermission, system, version = 1.0.5000.0, culture = neutral, publickeytoken = b77a5c561934e089 \ "\ r \ n version = \" 1 \ "\ r \ n Level = \" minimal \ "/> \ r \ n </permissionset> \ r \ N "), permissionset (securityaction. inheritancedemand, xml = "<permissionset class = \" system. security. permissionset \ "\ r \ n version = \" 1 \ "> \ r \ n <ipermission class = \" system. web. aspnethostingpermission, system, version = 1.0.5000.0, culture = neutral, publickeytoken = b77a5c561934e089 \ "\ r \ n version = \" 1 \ "\ r \ n Level = \" minimal \ "/> \ r \ n </permissionset> \ r \ N ")]
Public class textbox: webcontrol, ipostbackdatahandler
{
// Fields
Private Static readonly object eventtextchanged = new object ();
// Events
[Webcategory ("action"), websysdescription ("textbox_ontextchanged")]
Public event eventhandler textchanged
{
Add
{
Base. Events. addhandler (eventtextchanged, value );
}
Remove
{
Base. Events. removehandler (eventtextchanged, value );
}
}
// Methods
Public Textbox (): Base (htmltextwritertag. Input)
{
}
Protected override void addattributestorender (htmltextwriter writer)
{
Int maxlength;
If (this. Page! = NULL)
{
This. Page. verifyrenderinginserverform (this );
}
Writer. addattribute (htmltextwriterattribute. Name, this. uniqueid );
Switch (this. textmode)
{
Case textboxmode. singleline:
{
Writer. addattribute (htmltextwriterattribute. type, "text ");
String text = This. text;
If (text. length> 0)
{
Writer. addattriter( htmltextwriterattribute. Value, text );
}
Break;
}
Case textboxmode. Password:
Writer. addattribute (htmltextwriterattribute. type, "password ");
Break;
Case textboxmode. multiline:
Maxlength = This. Rows;
If (maxlength> 0)
{
Writer. addattribute (htmltextwriterattribute. Rows, maxlength. tostring (numberformatinfo. invariantinfo ));
}
Maxlength = This. columns;
If (maxlength> 0)
{
Writer. addattribute (htmltextwriterattribute. cols, maxlength. tostring (numberformatinfo. invariantinfo ));
}
If (! This. Wrap)
{
Writer. addattribute (htmltextwriterattribute. Wrap, "off ");
}
Goto label_00ff;
}
Maxlength = This. maxlength;
If (maxlength> 0)
{
Writer. addattribute (htmltextwriterattribute. maxlength, maxlength. tostring (numberformatinfo. invariantinfo ));
}
Maxlength = This. columns;
If (maxlength> 0)
{
Writer. addattribute (htmltextwriterattribute. Size, maxlength. tostring (numberformatinfo. invariantinfo ));
}
Label_00ff:
If (this. readonly)
{
Writer. addattribute (htmltextwriterattribute. readonly, "readonly ");
}
If (this. autopostback & (this. Page! = NULL ))
{
String postbackclientevent = This. Page. getpostbackclientevent (this ,"");
If (base. hasattributes)
{
String str3 = base. attributes ["onchange"];
If (str3! = NULL)
{
Postbackclientevent = str3 + postbackclientevent;
Base. Attributes. Remove ("onchange ");
}
}
Writer. addattribute (htmltextwriterattribute. onchange, postbackclientevent );
Writer. addattribute ("language", "JavaScript ");
}
Base. addattributestorender (writer );
}
Protected override void addparsedsubobject (Object OBJ)
{
If (! (Obj is literalcontrol ))
{
Throw new httpexception (httpruntime. formatresourcestring ("cannot_have_children_of_type", "textbox", obj. GetType (). Name. tostring ()));
}
This. Text = (literalcontrol) OBJ). text;
}
Protected override void onprerender (eventargs E)
{
Base. onprerender (E );
If (! This. savetextviewstate)
{
This. viewstate. setitemdirty ("text", false );
}
If (this. Page! = NULL) & this. autopostback) & this. enabled)
{
This. Page. registerpostbackscript ();
}
}
Protected virtual void ontextchanged (eventargs E)
{
Eventhandler handler = (eventhandler) base. events [eventtextchanged];
If (handler! = NULL)
{
Handler (this, e );
}
}
Protected override void render (htmltextwriter writer)
{
This. renderbegintag (writer );
If (this. textmode = textboxmode. multiline)
{
Httputility. htmlencode (this. Text, writer );
}
This. renderendtag (writer );
}
Bool ipostbackdatahandler. loadpostdata (string postdatakey, namevaluecollection postcollection)
{
String text = This. text;
String str2 = postcollection [postdatakey];
If (! Text. Equals (str2 ))
{
This. Text = str2;
Return true;
}
Return false;
}
Void ipostbackdatahandler. raisepostdatachangedevent ()
{
This. ontextchanged (eventargs. Empty );
}
// Properties
[Webcategory ("behavior"), websysdescription ("textbox_autopostback"), defaultvalue (false)]
Public Virtual bool autopostback
{
Get
{
Object obj2 = This. viewstate ["autopostback"];
Return (obj2! = NULL) & (bool) obj2 ));
}
Set
{
This. viewstate ["autopostback"] = value;
}
}
[defaultvalue (0), websysdescription ("textbox_columns"), Bindable (true), webcategory ("appearance")]
Public Virtual int columns
{< br> Get
{< br> Object obj2 = this. viewstate ["columns"];
If (obj2! = NULL)
{< br> return (INT) obj2;
}< br> return 0;
}< br> set
{< br> If (value <0)
{< br> throw new argumentoutofrangeexception ("value ");
}< br> This. viewstate ["columns"] = value;
}< BR >}
[Bindable (true), webcategory ("behavior"), defaultvalue (0), websysdescription ("textbox_maxlength")]
Public Virtual int maxlength
{
Get
{
Object obj2 = This. viewstate ["maxlength"];
If (obj2! = NULL)
{
Return (INT) obj2;
}
Return 0;
}
Set
{
If (value <0)
{
Throw new argumentoutofrangeexception ("value ");
}
This. viewstate ["maxlength"] = value;
}
}
[Webcategory ("behavior"), Bindable (true), defaultvalue (false), websysdescription ("textbox_readonly")]
Public Virtual bool readonly
{
Get
{
Object obj2 = This. viewstate ["readonly"];
Return (obj2! = NULL) & (bool) obj2 ));
}
Set
{
This. viewstate ["readonly"] = value;
}
}
[Bindable (true), webcategory ("behavior"), defaultvalue (0), websysdescription ("textbox_rows")]
Public Virtual int rows
{
Get
{
Object obj2 = This. viewstate ["rows"];
If (obj2! = NULL)
{
Return (INT) obj2;
}
Return 0;
}
Set
{
If (value <0)
{
Throw new argumentoutofrangeexception ("value ");
}
This. viewstate ["rows"] = value;
}
}
Private bool savetextviewstate
{
Get
{
If (this. textmode = textboxmode. Password)
{
Return false;
}
If (base. events [eventtextchanged] = NULL) & this. enabled) & (this. visible & (base. getType () = typeof (textbox ))))
{
Return false;
}
Return true;
}
}
Protected override htmltextwritertag tagkey
{
Get
{
If (this. textmode = textboxmode. multiline)
{
Return htmltextwritertag. textarea;
}
Return htmltextwritertag. input;
}
}
[Bindable (true), webcategory ("appearance"), defaultvalue (""), websysdescription ("textbox_text"), persistencemode (persistencemode. encodedinnerdefadefaproperty)]
Public Virtual string text
{
Get
{
String STR = (string) This. viewstate ["text"];
If (STR! = NULL)
{
Return STR;
}
Return string. empty;
}
Set
{
This. viewstate ["text"] = value;
}
}
[defaultvalue (0), websysdescription ("textbox_textmode"), webcategory ("behavior")]
Public Virtual textboxmode textmode
{< br> Get
{< br> Object obj2 = this. viewstate ["Mode"];
If (obj2! = NULL)
{< br> return (textboxmode) obj2;
}< br> return textboxmode. singleline;
}< br> set
{< br> If (value textboxmode. password)
{< br> throw new argumentoutofrangeexception ("value");
}< br> This. viewstate ["Mode"] = value;
}< BR >}
[Webcategory ("layout"), defaultvalue (true), websysdescription ("textbox_wrap")]
Public Virtual bool wrap
{
Get
{
Object obj2 = This. viewstate ["Wrap"];
If (obj2! = NULL)
{
Return (bool) obj2;
}
Return true;
}
Set
{
This. viewstate ["Wrap"] = value;
}
}
}