Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TextBox.cs « WebControls « UI « System.Web « referencesource « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 35e7c2844fc35c85d84de97fbac028f91ff3c3b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
//------------------------------------------------------------------------------
// <copyright file="TextBox.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

namespace System.Web.UI.WebControls {
    using System;
    using System.Collections.Specialized;
    using System.ComponentModel;
    using System.Drawing.Design;
    using System.Globalization;
    using System.Web;
    using System.Web.UI;
    using System.Web.Util;

    /// <devdoc>
    /// <para>Interacts with the parser to build a <see cref='System.Web.UI.WebControls.TextBox'/> control.</para>
    /// </devdoc>
    public class TextBoxControlBuilder : ControlBuilder {


        /// <internalonly/>
        /// <devdoc>
        ///    Specifies whether white space literals are allowed.
        /// </devdoc>
        public override bool AllowWhitespaceLiterals() {
            return false;
        }


        public override bool HtmlDecodeLiterals() {
            // TextBox text gets rendered as an encoded attribute value or encoded content.

            // At parse time text specified as an attribute gets decoded, and so text specified as a
            // literal needs to go through the same process.

            return true;
        }
    }



    /// <devdoc>
    ///    <para>Constructs a text box and defines its properties.</para>
    /// </devdoc>
    [
    ControlBuilderAttribute(typeof(TextBoxControlBuilder)),
    ControlValueProperty("Text"),
    DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + AssemblyRef.SystemDesign),
    DefaultProperty("Text"),
    ValidationProperty("Text"),
    DefaultEvent("TextChanged"),
    Designer("System.Web.UI.Design.WebControls.PreviewControlDesigner, " + AssemblyRef.SystemDesign),
    ParseChildren(true, "Text"),
    SupportsEventValidation,
    ]
    public class TextBox : WebControl, IPostBackDataHandler, IEditableTextControl {

        private static readonly object EventTextChanged = new Object();

        private const string _textBoxKeyHandlerCall = "if (WebForm_TextBoxKeyHandler(event) == false) return false;";

        private const int DefaultMutliLineRows = 2;
        private const int DefaultMutliLineColumns = 20;

        /// <devdoc>
        /// <para>Initializes a new instance of the <see cref='System.Web.UI.WebControls.TextBox'/> class.</para>
        /// </devdoc>
        public TextBox() : base(HtmlTextWriterTag.Input) {
        }


        [
        DefaultValue(AutoCompleteType.None),
        Themeable(false),
        WebCategory("Behavior"),
        WebSysDescription(SR.TextBox_AutoCompleteType)
        ]
        public virtual AutoCompleteType AutoCompleteType {
            get {
                object obj = ViewState["AutoCompleteType"];
                return (obj == null) ? AutoCompleteType.None : (AutoCompleteType) obj;
            }
            set {
                if (value < AutoCompleteType.None || value > AutoCompleteType.Enabled) {
                    throw new ArgumentOutOfRangeException("value");
                }
                ViewState["AutoCompleteType"] = value;
            }
        }


        /// <devdoc>
        ///    <para>Gets or sets a value indicating whether an automatic
        ///       postback to the server will occur whenever the user changes the
        ///       content of the text box.</para>
        /// </devdoc>
        [
        DefaultValue(false),
        Themeable(false),
        WebCategory("Behavior"),
        WebSysDescription(SR.TextBox_AutoPostBack),
        ]
        public virtual bool AutoPostBack {
            get {
                object b = ViewState["AutoPostBack"];
                return((b == null) ? false : (bool)b);
            }
            set {
                ViewState["AutoPostBack"] = value;
            }
        }


        [
        DefaultValue(false),
        Themeable(false),
        WebCategory("Behavior"),
        WebSysDescription(SR.AutoPostBackControl_CausesValidation)
        ]
        public virtual bool CausesValidation {
            get {
                object b = ViewState["CausesValidation"];
                return((b == null) ? false : (bool)b);
            }
            set {
                ViewState["CausesValidation"] = value;
            }
        }


        /// <devdoc>
        ///    <para>Gets or sets the display
        ///       width of the text box in characters.</para>
        /// </devdoc>
        [
        WebCategory("Appearance"),
        DefaultValue(0),
        WebSysDescription(SR.TextBox_Columns)
        ]
        public virtual int Columns {
            get {
                object o = ViewState["Columns"];
                return((o == null) ? 0 : (int)o);
            }
            set {
                if (value < 0) {
                    throw new ArgumentOutOfRangeException("Columns", SR.GetString(SR.TextBox_InvalidColumns));
                }
                ViewState["Columns"] = value;
            }
        }


        /// <devdoc>
        ///    <para>Gets or sets the maximum number of characters allowed in the text box.</para>
        /// </devdoc>
        [
        DefaultValue(0),
        Themeable(false),
        WebCategory("Behavior"),
        WebSysDescription(SR.TextBox_MaxLength),
        ]
        public virtual int MaxLength {
            get {
                object o = ViewState["MaxLength"];
                return((o == null) ? 0 : (int)o);
            }
            set {
                if (value < 0) {
                    throw new ArgumentOutOfRangeException("value");
                }
                ViewState["MaxLength"] = value;
            }
        }


        /// <devdoc>
        ///    <para>
        ///       Gets or sets the behavior mode of the text box.</para>
        /// </devdoc>
        [
        DefaultValue(TextBoxMode.SingleLine),
        Themeable(false),
        WebCategory("Behavior"),
        WebSysDescription(SR.TextBox_TextMode)
        ]
        public virtual TextBoxMode TextMode {
            get {
                object mode = ViewState["Mode"];
                return((mode == null) ? TextBoxMode.SingleLine : (TextBoxMode)mode);
            }
            set {
                if (value < TextBoxMode.SingleLine || value > TextBoxMode.Week) {
                    throw new ArgumentOutOfRangeException("value");
                }
                ViewState["Mode"] = value;
            }
        }


        /// <devdoc>
        ///    <para>Whether the textbox is in read-only mode.</para>
        /// </devdoc>
        [
        Bindable(true),
        DefaultValue(false),
        Themeable(false),
        WebCategory("Behavior"),
        WebSysDescription(SR.TextBox_ReadOnly)
        ]
        public virtual bool ReadOnly {
            get {
                object o = ViewState["ReadOnly"];
                return((o == null) ? false : (bool)o);
            }
            set {
                ViewState["ReadOnly"] = value;
            }
        }


        /// <devdoc>
        ///    <para> Gets or sets the display height of a multiline text box.</para>
        /// </devdoc>
        [
        DefaultValue(0),
        Themeable(false),
        WebCategory("Behavior"),
        WebSysDescription(SR.TextBox_Rows)
        ]
        public virtual int Rows {
            get {
                object o = ViewState["Rows"];
                return((o == null) ? 0 : (int)o);
            }
            set {
                if (value < 0) {
                    throw new ArgumentOutOfRangeException("Rows", SR.GetString(SR.TextBox_InvalidRows));
                }
                ViewState["Rows"] = value;
            }
        }

        /// <devdoc>
        ///    Determines whether the Text must be stored in view state, to
        ///    optimize the size of the saved state.
        /// </devdoc>
        private bool SaveTextViewState {
            get {
                // 


                // Must be saved when
                // 1. There is a registered event handler for SelectedIndexChanged
                // 2. Control is not enabled or visible, because the browser's post data will not include this control
                // 3. The instance is a derived instance, which might be overriding the OnTextChanged method

                if (TextMode == TextBoxMode.Password) {
                    return false;
                }

                if ((Events[EventTextChanged] != null) ||
                    (IsEnabled == false) ||
                    (Visible == false) ||
                    (ReadOnly) ||
                    (this.GetType() != typeof(TextBox))) {
                    return true;
                }

                return false;
            }
        }


        /// <devdoc>
        ///    <para>A protected property. Gets the HTML tag
        ///       for the text box control.</para>
        /// </devdoc>
        protected override HtmlTextWriterTag TagKey {
            get {
                if (TextMode == TextBoxMode.MultiLine)
                    return HtmlTextWriterTag.Textarea;
                else
                    return HtmlTextWriterTag.Input;
            }
        }


        /// <devdoc>
        ///    <para> Gets
        ///       or sets the text content of the text box.</para>
        /// </devdoc>
        [
        Localizable(true),
        Bindable(true, BindingDirection.TwoWay),
        WebCategory("Appearance"),
        DefaultValue(""),
        WebSysDescription(SR.TextBox_Text),
        PersistenceMode(PersistenceMode.EncodedInnerDefaultProperty),
        Editor("System.ComponentModel.Design.MultilineStringEditor," + AssemblyRef.SystemDesign, typeof(UITypeEditor))
        ]
        public virtual string Text {
            get {
                string s = (string)ViewState["Text"];
                return((s == null) ? String.Empty : s);
            }
            set {
                ViewState["Text"] = value;
            }
        }


        [
        WebCategory("Behavior"),
        Themeable(false),
        DefaultValue(""),
        WebSysDescription(SR.PostBackControl_ValidationGroup)
        ]
        public virtual string ValidationGroup {
            get {
                string s = (string)ViewState["ValidationGroup"];
                return((s == null) ? string.Empty : s);
            }
            set {
                ViewState["ValidationGroup"] = value;
            }
        }


        /// <devdoc>
        ///    Gets or sets a value indicating whether the
        ///    text content wraps within the text box.
        /// </devdoc>
        [
        WebCategory("Layout"),
        DefaultValue(true),
        WebSysDescription(SR.TextBox_Wrap)
        ]
        public virtual bool Wrap {
            get {
                object b = ViewState["Wrap"];
                return((b == null) ? true : (bool)b);
            }
            set {
                ViewState["Wrap"] = value;
            }
        }

        // internal for unit testing
        internal virtual bool SupportsVCard {
            get {
                return Context != null && Context.Request.Browser["supportsVCard"] == "true";
            }
        }

        /// <devdoc>
        ///    <para>Occurs when the content of the text box is
        ///       changed upon server postback.</para>
        /// </devdoc>
        [
        WebCategory("Action"),
        WebSysDescription(SR.TextBox_OnTextChanged)
        ]
        public event EventHandler TextChanged {
            add {
                Events.AddHandler(EventTextChanged, value);
            }
            remove {
                Events.RemoveHandler(EventTextChanged, value);
            }
        }


        /// <internalonly/>
        /// <devdoc>
        /// </devdoc>
        protected override void AddAttributesToRender(HtmlTextWriter writer) {

            // Make sure we are in a form tag with runat=server.
            Page page = Page;
            if (page != null) {
                page.VerifyRenderingInServerForm(this);
            }

            string uniqueID = UniqueID;
            if (uniqueID != null) {
                writer.AddAttribute(HtmlTextWriterAttribute.Name, uniqueID);
            }

            TextBoxMode mode = TextMode;

            if (mode == TextBoxMode.MultiLine) {
                // MultiLine renders as textarea

                int rows = Rows;
                int columns = Columns;
                bool adapterRenderZeroRowCol = false;

                if (!EnableLegacyRendering) {
                    // VSWhidbey 497755
                    if (rows == 0) {
                        rows = DefaultMutliLineRows;
                    }
                    if (columns == 0) {
                        columns = DefaultMutliLineColumns;
                    }
                }

                if (rows > 0 || adapterRenderZeroRowCol) {
                    writer.AddAttribute(HtmlTextWriterAttribute.Rows, rows.ToString(NumberFormatInfo.InvariantInfo));
                }

                if (columns > 0 || adapterRenderZeroRowCol) {
                    writer.AddAttribute(HtmlTextWriterAttribute.Cols, columns.ToString(NumberFormatInfo.InvariantInfo));
                }

                if (!Wrap) {
                    writer.AddAttribute(HtmlTextWriterAttribute.Wrap,"off");
                }
            }
            else {
                // Everything else renders as input

                if (mode != TextBoxMode.SingleLine || String.IsNullOrEmpty(Attributes["type"])) {
                    // If the developer specified a custom type (like an HTML 5 type), use that type instead of "text".
                    // The call to base.AddAttributesToRender at the end of this method will add the custom type if specified.
                    writer.AddAttribute(HtmlTextWriterAttribute.Type, GetTypeAttributeValue(mode));
                }

                AutoCompleteType autoCompleteType = AutoCompleteType;
                if (mode == TextBoxMode.SingleLine &&
                    autoCompleteType != AutoCompleteType.None &&
                    autoCompleteType != AutoCompleteType.Enabled &&
                    autoCompleteType != AutoCompleteType.Disabled &&
                    SupportsVCard) {

                    // Renders the vcard_name attribute so that client browsers can support autocomplete
                    string name = GetVCardAttributeValue(autoCompleteType);
                    writer.AddAttribute(HtmlTextWriterAttribute.VCardName, name);
                }

                if (autoCompleteType == AutoCompleteType.Disabled &&
                    (RenderingCompatibility >= VersionUtil.Framework45 || mode >= TextBoxMode.Color || (SupportsVCard && mode == TextBoxMode.SingleLine))) {
                    // Only render autocomplete="off" when one of the following is true
                    // - 4.5 or higher rendering compat is being used
                    // - any of the new HTML5 modes are being used
                    // - browser supports vCard AND mode is SingleLine (this is the legacy pre-4.5 behavior)
                    writer.AddAttribute(HtmlTextWriterAttribute.AutoComplete, "off");
                }

                if (autoCompleteType == AutoCompleteType.Enabled) {
                    // Since Enabled is a new value in .NET 4.5 we don't need back-compat switches
                    writer.AddAttribute(HtmlTextWriterAttribute.AutoComplete, "on");
                }

                if (mode != TextBoxMode.Password) {
                    // only render value if we're not a password
                    string s = Text;
                    if (s.Length > 0) {
                        writer.AddAttribute(HtmlTextWriterAttribute.Value, s);
                    }
                }

                int n = MaxLength;
                if (n > 0) {
                    writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, n.ToString(NumberFormatInfo.InvariantInfo));
                }
                n = Columns;
                if (n > 0) {
                    writer.AddAttribute(HtmlTextWriterAttribute.Size, n.ToString(NumberFormatInfo.InvariantInfo));
                }
            }

            if (ReadOnly) {
                writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly");
            }

            if (AutoPostBack && (page != null) && page.ClientSupportsJavaScript) {
                string onChange = null;
                if (HasAttributes) {
                    onChange = Attributes["onchange"];
                    if (onChange != null) {
                        onChange = Util.EnsureEndWithSemiColon(onChange);
                        Attributes.Remove("onchange");
                    }
                }

                PostBackOptions options = new PostBackOptions(this, String.Empty);

                // ASURT 98368
                // Need to merge the autopostback script with the user script
                if (CausesValidation) {
                    options.PerformValidation = true;
                    options.ValidationGroup = ValidationGroup;
                }

                if (page.Form != null) {
                    options.AutoPostBack = true;
                }

                onChange = Util.MergeScript(onChange, page.ClientScript.GetPostBackEventReference(options, true));
                writer.AddAttribute(HtmlTextWriterAttribute.Onchange, onChange);

                // VSWhidbey 482068: Enter key should be preserved in mult-line
                // textbox so the textBoxKeyHandlerCall should not be hooked up
                if (mode != TextBoxMode.MultiLine) {
                    string onKeyPress = _textBoxKeyHandlerCall;
                    if (HasAttributes) {
                        string userOnKeyPress = Attributes["onkeypress"];
                        if (userOnKeyPress != null) {
                            onKeyPress += userOnKeyPress;
                            Attributes.Remove("onkeypress");
                        }
                    }
                    writer.AddAttribute("onkeypress", onKeyPress);
                }

                if (EnableLegacyRendering) {
                    writer.AddAttribute("language", "javascript", false);
                }
            }
            else if (page != null) {
                page.ClientScript.RegisterForEventValidation(this.UniqueID, String.Empty);
            }

            if (Enabled && !IsEnabled && SupportsDisabledAttribute) {
                // We need to do the cascade effect on the server, because the browser
                // only renders as disabled, but doesn't disable the functionality.
                writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
            }

            base.AddAttributesToRender(writer);
        }

        /// <internalonly/>
        /// <devdoc>
        ///    Overridden to only allow literal controls to be added as Text property.
        /// </devdoc>
        protected override void AddParsedSubObject(object obj) {
            if (obj is LiteralControl) {
                Text = ((LiteralControl)obj).Text;
            }
            else {
                throw new HttpException(SR.GetString(SR.Cannot_Have_Children_Of_Type, "TextBox", obj.GetType().Name.ToString(CultureInfo.InvariantCulture)));
            }
        }

        internal static string GetTypeAttributeValue(TextBoxMode mode) {
            switch (mode) {
                case TextBoxMode.SingleLine: return "text";
                case TextBoxMode.Password: return "password";
                case TextBoxMode.Color: return "color";
                case TextBoxMode.Date: return "date";
                case TextBoxMode.DateTime: return "datetime";
                case TextBoxMode.DateTimeLocal: return "datetime-local";
                case TextBoxMode.Email: return "email";
                case TextBoxMode.Month: return "month";
                case TextBoxMode.Number: return "number";
                case TextBoxMode.Range: return "range";
                case TextBoxMode.Search: return "search";
                case TextBoxMode.Phone: return "tel";
                case TextBoxMode.Time: return "time";
                case TextBoxMode.Url: return "url";
                case TextBoxMode.Week: return "week";
                case TextBoxMode.MultiLine:
                    // falling through on purpose
                default:
                    // the default case could only happen if
                    //  - someone forces an out-of-range value as a TextBoxMode and passes it in
                    //  - a new TextBoxMode value gets added, in which case it should be handled as an explicit case above
                    throw new InvalidOperationException();
            }
        }

        internal static string GetVCardAttributeValue(AutoCompleteType type) {
            switch (type) {
                case AutoCompleteType.None:
                case AutoCompleteType.Disabled:
                case AutoCompleteType.Enabled:
                    // should not happen
                    throw new InvalidOperationException();
                case AutoCompleteType.Search:
                    return "search";
                case AutoCompleteType.HomeCountryRegion:
                    return "HomeCountry";
                case AutoCompleteType.BusinessCountryRegion:
                    return "BusinessCountry";
                default:
                    string result = Enum.Format(typeof(AutoCompleteType), type, "G");
                    // Business and Home properties need to be prefixed with "."
                    if (result.StartsWith("Business", StringComparison.Ordinal)) {
                        result = result.Insert(8, ".");
                    }
                    else if (result.StartsWith("Home", StringComparison.Ordinal)) {
                        result = result.Insert(4, ".");
                    }
                    return "vCard." + result;
            }
        }

        /// <internalonly/>
        protected internal override void OnPreRender(EventArgs e) {
            base.OnPreRender(e);

            Page page = Page;
            if ((page != null) && IsEnabled) {
                if (SaveTextViewState == false) {
                    // Store a client-side array of enabled control, so we can re-enable them on
                    // postback (in case they are disabled client-side)
                    // Postback is needed when view state for the Text property is disabled
                    page.RegisterEnabledControl(this);
                }

                if (AutoPostBack) {
                    page.RegisterWebFormsScript();
                    page.RegisterPostBackScript();
                    page.RegisterFocusScript();
                }
            }
        }


        /// <internalonly/>
        /// <devdoc>
        /// <para>Loads the posted text box content if it is different
        /// from the last posting.</para>
        /// </devdoc>
        bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection) {
            return LoadPostData(postDataKey, postCollection);
        }


        /// <internalonly/>
        /// <devdoc>
        /// <para>Loads the posted text box content if it is different
        /// from the last posting.</para>
        /// </devdoc>
        protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection) {
            ValidateEvent(postDataKey);

            string current = Text;
            string postData = postCollection[postDataKey];

            // VSWhidbey 442850: Everett had current.Equals(postData), and it is
            // equivalent to the option StringComparison.Ordinal in Whidbey
            if (!ReadOnly && !current.Equals(postData, StringComparison.Ordinal)) {
                Text = postData;
                return true;
            }
            return false;
        }



        /// <devdoc>
        /// <para> Raises the <see langword='TextChanged'/> event.</para>
        /// </devdoc>
        protected virtual void OnTextChanged(EventArgs e) {
            EventHandler onChangeHandler = (EventHandler)Events[EventTextChanged];
            if (onChangeHandler != null) onChangeHandler(this,e);
        }


        /// <internalonly/>
        /// <devdoc>
        /// <para>Invokes the <see cref='System.Web.UI.WebControls.TextBox.OnTextChanged'/> method
        /// whenever posted data for the text box has changed.</para>
        /// </devdoc>
        void IPostBackDataHandler.RaisePostDataChangedEvent() {
            RaisePostDataChangedEvent();
        }


        /// <internalonly/>
        /// <devdoc>
        /// <para>Invokes the <see cref='System.Web.UI.WebControls.TextBox.OnTextChanged'/> method
        /// whenever posted data for the text box has changed.</para>
        /// </devdoc>
        protected virtual void RaisePostDataChangedEvent() {
            if (AutoPostBack && !Page.IsPostBackEventControlRegistered) {
                // VSWhidbey 204824
                Page.AutoPostBackControl = this;

                if (CausesValidation) {
                     Page.Validate(ValidationGroup);
                }
             }
             OnTextChanged(EventArgs.Empty);
        }


        /// <internalonly/>
        /// <devdoc>
        /// </devdoc>
        protected internal override void Render(HtmlTextWriter writer) {
            RenderBeginTag(writer);
            //Dev10 Bug 483896: Original TextBox rendering in MultiLine mode suffers from the
            //problem of losing the first newline. We fixed this bug by always rendering a newline
            //before rendering the value of the Text property.
            if (TextMode == TextBoxMode.MultiLine) {
                //Dev11 Bug 437709 fix: We do not want to encode the extra new line that we are
                //rendering. However we are doing this only for 4.5 or later frameworks for back-compat.
                if (RenderingCompatibility >= VersionUtil.Framework45) {
                    writer.Write(System.Environment.NewLine);
                    HttpUtility.HtmlEncode(Text, writer);
                }
                else {
                    HttpUtility.HtmlEncode(System.Environment.NewLine + Text, writer);
                }
            }
            RenderEndTag(writer);
        }

        protected override object SaveViewState() {
            if (SaveTextViewState == false) {
                ViewState.SetItemDirty("Text", false);
            }
            return base.SaveViewState();
        }
    }
}