diff options
author | Marek Habersack <grendel@twistedcode.net> | 2010-06-21 22:42:26 +0400 |
---|---|---|
committer | Marek Habersack <grendel@twistedcode.net> | 2010-06-21 22:42:26 +0400 |
commit | a850c3df61a8d158555b90305abd68c55d261cdc (patch) | |
tree | d9a7b02c1b3d21be405f552646fb47671d75950b /mcs | |
parent | 16082ea5af87d2bce1eecae51ddff681e0342bf1 (diff) |
Backport of r159280
svn path=/branches/mono-2-6/mcs/; revision=159281
Diffstat (limited to 'mcs')
23 files changed, 113 insertions, 91 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs b/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs index 0d704ffa983..8ec6ceaef39 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/BaseValidator.cs @@ -234,7 +234,7 @@ namespace System.Web.UI.WebControls { if (SetFocusOnError) RegisterExpandoAttribute (ClientID, "focusOnError", "t"); #endif - if (!Enabled) + if (!IsEnabled) #if NET_2_0 RegisterExpandoAttribute (ClientID, "enabled", "False"); #else @@ -242,7 +242,7 @@ namespace System.Web.UI.WebControls { #endif #if NET_2_0 - if (Enabled && !IsValid) { + if (IsEnabled && !IsValid) { RegisterExpandoAttribute (ClientID, "isvalid", "False"); #else if (!IsValid) { @@ -510,7 +510,7 @@ document.getElementById('" + ClientID + @"').dispose = function() { override void Render (HtmlTextWriter writer) { #if NET_2_0 - if (!Enabled && !EnableClientScript) + if (!IsEnabled && !EnableClientScript) return; #endif if (render_uplevel) { @@ -576,7 +576,7 @@ document.getElementById('" + ClientID + @"').dispose = function() { #endif void Validate () { - if (Enabled && Visible) + if (IsEnabled && Visible) IsValid = ControlPropertiesValid () && EvaluateIsValid (); else IsValid = true; diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs index fac29e6d7e0..443fb2db3f0 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/BulletedList.cs @@ -131,9 +131,9 @@ namespace System.Web.UI.WebControls { break; case BulletedListDisplayMode.HyperLink: - if (Enabled && item.Enabled) { + if (IsEnabled && item.Enabled) { writer.AddAttribute (HtmlTextWriterAttribute.Href, item.Value); - if (Target != "") + if (Target.Length > 0) writer.AddAttribute(HtmlTextWriterAttribute.Target, this.Target); } @@ -146,7 +146,7 @@ namespace System.Web.UI.WebControls { break; case BulletedListDisplayMode.LinkButton: - if (Enabled && item.Enabled) + if (IsEnabled && item.Enabled) writer.AddAttribute (HtmlTextWriterAttribute.Href, Page.ClientScript.GetPostBackEventReference (GetPostBackOptions (index.ToString (Helpers.InvariantCulture)), true)); else writer.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled", false); @@ -301,7 +301,7 @@ namespace System.Web.UI.WebControls { [DefaultValueAttribute ("")] [TypeConverter (typeof (TargetConverter))] public virtual string Target { - get { return ViewState.GetString ("Target", ""); } + get { return ViewState.GetString ("Target", String.Empty); } set { ViewState ["Target"] = value; } } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs index 15eb1fb1ec0..3f799e53446 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs @@ -818,17 +818,18 @@ namespace System.Web.UI.WebControls { writer.RenderBeginTag (HtmlTextWriterTag.Table); #if NET_2_0 - if (Caption != "") + if (!String.IsNullOrEmpty (Caption)) WriteCaption (writer); #endif - + bool enabled = IsEnabled; + if (ShowTitle) - WriteTitle (writer); - + WriteTitle (writer, enabled); + if (ShowDayHeader) - WriteDayHeader (writer); + WriteDayHeader (writer, enabled); - WriteDays (writer); + WriteDays (writer, enabled); writer.RenderEndTag (); } @@ -914,7 +915,7 @@ namespace System.Web.UI.WebControls { // // Private methods // - void WriteDayHeader (HtmlTextWriter writer) + void WriteDayHeader (HtmlTextWriter writer, bool enabled) { int i, first; string dayName; @@ -942,7 +943,7 @@ namespace System.Web.UI.WebControls { int days = DateTime.DaysInMonth (DisplayDate.Year, DisplayDate.Month); selector.RenderBeginTag (writer); - writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + days, SelectMonthText, DayHeaderStyle.ForeColor, Enabled)); + writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + days, SelectMonthText, DayHeaderStyle.ForeColor, enabled)); selector.RenderEndTag (writer); } } @@ -1003,7 +1004,7 @@ namespace System.Web.UI.WebControls { writer.RenderEndTag (); } - void WriteDay (DateTime date, HtmlTextWriter writer) + void WriteDay (DateTime date, HtmlTextWriter writer, bool enabled) { TableItemStyle style = new TableItemStyle (); TableCell cell = new TableCell (); @@ -1039,7 +1040,7 @@ namespace System.Web.UI.WebControls { style.CopyFrom (otherMonthDayStyle); } - if (day.IsSelected && Enabled) { + if (enabled && day.IsSelected) { style.BackColor = Color.Silver; style.ForeColor = Color.White; if (selectedDayStyle != null && !selectedDayStyle.IsEmpty) { @@ -1050,12 +1051,12 @@ namespace System.Web.UI.WebControls { cell.ApplyStyle (style); lit.Text = BuildLink (GetDaysFromZenith (date).ToString (), day.DayNumberText, - cell.ForeColor, day.IsSelectable && Enabled); + cell.ForeColor, enabled && day.IsSelectable); cell.RenderControl (writer); } - void WriteDays (HtmlTextWriter writer) + void WriteDays (HtmlTextWriter writer, bool enabled) { DateTime date = new DateTime (DisplayDate.Year, DisplayDate.Month, 1); // first date DateTime lastDate; @@ -1087,12 +1088,12 @@ namespace System.Web.UI.WebControls { } selectorCell.RenderBeginTag (writer); - writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + "07", SelectWeekText, selectorCell.ForeColor, Enabled)); + writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + "07", SelectWeekText, selectorCell.ForeColor, enabled)); selectorCell.RenderEndTag (writer); } for (int i = 0; i < daysInAWeek; i++) { - WriteDay (date, writer); + WriteDay (date, writer, enabled); date = GetGlobalCalendar().AddDays (date, 1); } @@ -1156,7 +1157,7 @@ namespace System.Web.UI.WebControls { } #endif - void WriteTitle (HtmlTextWriter writer) + void WriteTitle (HtmlTextWriter writer, bool enabled) { TableCell cellNextPrev = null; TableCell titleCell = new TableCell (); @@ -1191,7 +1192,7 @@ namespace System.Web.UI.WebControls { DateTime date = GetGlobalCalendar().AddMonths (DisplayDate, - 1); date = GetGlobalCalendar ().AddDays (date, -date.Day + 1); cellNextPrev.RenderBeginTag (writer); - writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, false), cellNextPrev.ForeColor, Enabled)); + writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, false), cellNextPrev.ForeColor, enabled)); cellNextPrev.RenderEndTag (writer); } @@ -1220,7 +1221,7 @@ namespace System.Web.UI.WebControls { cellNextPrev.HorizontalAlign = HorizontalAlign.Right; cellNextPrev.RenderBeginTag (writer); - writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, true), cellNextPrev.ForeColor, Enabled)); + writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, true), cellNextPrev.ForeColor, enabled)); cellNextPrev.RenderEndTag (writer); } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog index 6e464e6db6c..211e9607c2b 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog @@ -1,3 +1,13 @@ +2010-06-21 Marek Habersack <mhabersack@novell.com> + + * BaseValidator.cs, BulletedList.cs, Calendar.cs, CheckBox.cs, + CheckBoxList.cs, DataGrid.cs, DropDownList.cs, GridView.cs, + HyperLink.cs, ImageButton.cs, LinkButton.cs, ListBox.cs, + ListControl.cs, Menu.cs, RadioButton.cs, RadioButtonList.cs, + RepeatInfo.cs, Repeater.cs, TextBox.cs, TreeView.cs, + ValidationSummary.cs, WebControl.cs: use WebControl.IsEnabled + instead of Enabled wherever necessary. + 2010-06-16 Marek Habersack <mhabersack@novell.com> * FormView.cs: row values must be retrieved with inclusion of diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs index 733471f379e..78cffc45e72 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs @@ -299,15 +299,13 @@ namespace System.Web.UI.WebControls { { base.OnPreRender (e); Page page = Page; - bool enabled = Enabled; - if (page != null && enabled) { + if (page != null && IsEnabled) { page.RegisterRequiresPostBack (this); - } #if NET_2_0 - if (Page != null && enabled) page.RegisterEnabledControl (this); #endif + } } static bool IsInputOrCommonAttr (string attname) @@ -393,7 +391,8 @@ namespace System.Web.UI.WebControls { ControlStyle.AddAttributesToRender (w, this); } - if (!Enabled) { + bool enabled = IsEnabled; + if (!enabled) { w.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled", false); need_span = true; } @@ -417,26 +416,26 @@ namespace System.Web.UI.WebControls { TextAlign align = TextAlign; if (align == TextAlign.Right) { - RenderInput (w); + RenderInput (w, enabled); RenderLabel (w); } else { RenderLabel (w); - RenderInput (w); + RenderInput (w, enabled); } if (need_span) w.RenderEndTag (); } - void RenderInput (HtmlTextWriter w) { - + void RenderInput (HtmlTextWriter w, bool enabled) + { if (ClientID != null && ClientID.Length > 0) w.AddAttribute (HtmlTextWriterAttribute.Id, ClientID); w.AddAttribute (HtmlTextWriterAttribute.Type, render_type); string nameAttr = NameAttribute; if (nameAttr != null && nameAttr.Length > 0) w.AddAttribute (HtmlTextWriterAttribute.Name, nameAttr); - InternalAddAttributesToRender (w); + InternalAddAttributesToRender (w, enabled); #if NET_2_0 AddAttributesToRender (w); if (inputAttributes != null) @@ -489,7 +488,7 @@ namespace System.Web.UI.WebControls { #endif bool LoadPostData (string postDataKey, NameValueCollection postCollection) { - if (!Enabled) + if (!IsEnabled) return false; string postedValue = postCollection[postDataKey]; @@ -547,9 +546,9 @@ namespace System.Web.UI.WebControls { } #endif - internal virtual void InternalAddAttributesToRender (HtmlTextWriter w) + internal virtual void InternalAddAttributesToRender (HtmlTextWriter w, bool enabled) { - if (!Enabled) + if (!enabled) w.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled", false); } } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/CheckBoxList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/CheckBoxList.cs index f99689f38db..7f134db6faa 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/CheckBoxList.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/CheckBoxList.cs @@ -365,7 +365,7 @@ namespace System.Web.UI.WebControls { check_box.Checked = item.Selected; check_box.TextAlign = TextAlign; #if NET_2_0 - if (!Enabled) + if (!IsEnabled) check_box.Enabled = false; else check_box.Enabled = item.Enabled; diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs index ec072ab0a33..7be47cb9bc4 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs @@ -1078,7 +1078,7 @@ namespace System.Web.UI.WebControls { rt.Caption = Caption; rt.CaptionAlign = CaptionAlign; - rt.Enabled = Enabled; + rt.Enabled = IsEnabled; bool top_pager = true; foreach (DataGridItem item in rt.Rows) { diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs index 0db301ac787..4e08f4867b2 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/DropDownList.cs @@ -128,7 +128,7 @@ namespace System.Web.UI.WebControls { if (!String.IsNullOrEmpty (UniqueID)) writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID, true); - if (!Enabled && SelectedIndex == -1) + if (!IsEnabled && SelectedIndex == -1) SelectedIndex = 1; #else writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID, true); diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs b/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs index 3715d6c31a5..f586bdd919f 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/GridView.cs @@ -1364,8 +1364,7 @@ namespace System.Web.UI.WebControls } } return 0; - } - else { + } else { GridViewRow footerRow = CreateRow (-1, -1, DataControlRowType.Footer, DataControlRowState.Normal); InitializeRow (footerRow, fields); OnRowCreated (new GridViewRowEventArgs (footerRow)); diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs index b82d2b14ad7..e2e0d9448bb 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs @@ -59,7 +59,7 @@ namespace System.Web.UI.WebControls { #if NET_2_0 AddDisplayStyleAttribute (w); #endif - if (!Enabled) + if (!IsEnabled) return; // add attributes - only if they're not empty string t = Target; diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs index 2fe68688718..3d766433aca 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs @@ -371,8 +371,9 @@ namespace System.Web.UI.WebControls { #endif override void OnPreRender (EventArgs e) { - if (Page != null && Enabled) - Page.RegisterRequiresPostBack (this); + Page page = Page; + if (page != null && IsEnabled) + page.RegisterRequiresPostBack (this); } [WebSysDescription ("")] diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs index d6ce63a75e3..b1faa78fab6 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs @@ -60,9 +60,11 @@ namespace System.Web.UI.WebControls { protected override void AddAttributesToRender (HtmlTextWriter w) { - if (Page != null) - Page.VerifyRenderingInServerForm (this); + Page page = Page; + if (page != null) + page.VerifyRenderingInServerForm (this); + bool enabled = IsEnabled; #if NET_2_0 string onclick = OnClientClick; onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick); @@ -74,25 +76,25 @@ namespace System.Web.UI.WebControls { if (onclick.Length > 0) w.AddAttribute (HtmlTextWriterAttribute.Onclick, onclick); - if (Enabled && Page != null) { + if (enabled && page != null) { PostBackOptions options = GetPostBackOptions (); - string href = Page.ClientScript.GetPostBackEventReference (options, true); + string href = page.ClientScript.GetPostBackEventReference (options, true); w.AddAttribute (HtmlTextWriterAttribute.Href, href); } base.AddAttributesToRender (w); AddDisplayStyleAttribute (w); #else base.AddAttributesToRender (w); - if (Page == null || !Enabled) + if (page == null || !enabled) return; - if (CausesValidation && Page.AreValidatorsUplevel ()) { - ClientScriptManager csm = new ClientScriptManager (Page); + if (CausesValidation && page.AreValidatorsUplevel ()) { + ClientScriptManager csm = new ClientScriptManager (page); w.AddAttribute (HtmlTextWriterAttribute.Href, String.Concat ("javascript:{if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); ", csm.GetPostBackEventReference (this, String.Empty), ";}")); } else { - w.AddAttribute (HtmlTextWriterAttribute.Href, Page.ClientScript.GetPostBackClientHyperlink (this, "")); + w.AddAttribute (HtmlTextWriterAttribute.Href, page.ClientScript.GetPostBackClientHyperlink (this, String.Empty)); } #endif } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs index 2586a1ec204..da401fc5d5c 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListBox.cs @@ -208,8 +208,9 @@ namespace System.Web.UI.WebControls { override void OnPreRender (EventArgs e) { base.OnPreRender (e); - if (Page != null && Enabled) - Page.RegisterRequiresPostBack (this); + Page page = Page; + if (page != null && IsEnabled) + page.RegisterRequiresPostBack (this); } #if NET_2_0 diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs index aad10b02b28..b3800b7a905 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs @@ -408,8 +408,9 @@ namespace System.Web.UI.WebControls { { base.OnPreRender (e); #if NET_2_0 - if (Page != null && Enabled) - Page.RegisterEnabledControl (this); + Page page = Page; + if (page != null && IsEnabled) + page.RegisterEnabledControl (this); #endif } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs index 6973243bcfc..53292cc7cb1 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/Menu.cs @@ -903,7 +903,7 @@ namespace System.Web.UI.WebControls protected internal virtual void RaisePostBackEvent (string eventArgument) { ValidateEvent (UniqueID, eventArgument); - if (!Enabled) + if (!IsEnabled) return; EnsureChildControls(); diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs index 2f5ceaf2c17..85ea99d49c6 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/RadioButton.cs @@ -105,14 +105,14 @@ namespace System.Web.UI.WebControls { } } - internal override void InternalAddAttributesToRender (HtmlTextWriter w) + internal override void InternalAddAttributesToRender (HtmlTextWriter w, bool enabled) { #if NET_2_0 Page page = Page; if (page != null) page.ClientScript.RegisterForEventValidation (NameAttribute, ValueAttribute); #endif - base.InternalAddAttributesToRender (w); + base.InternalAddAttributesToRender (w, enabled); w.AddAttribute (HtmlTextWriterAttribute.Value, ValueAttribute); } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs index b8ee5afaf28..df98ac8028f 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/RadioButtonList.cs @@ -255,7 +255,7 @@ namespace System.Web.UI.WebControls { radio.Checked = item.Selected; radio.ValueAttribute = item.Value; radio.AutoPostBack = AutoPostBack; - radio.Enabled = Enabled; + radio.Enabled = IsEnabled; radio.TabIndex = tabIndex; #if NET_2_0 radio.ValidationGroup = ValidationGroup; diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/RepeatInfo.cs b/mcs/class/System.Web/System.Web.UI.WebControls/RepeatInfo.cs index e86d9bbda33..b1e275a8218 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/RepeatInfo.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/RepeatInfo.cs @@ -414,7 +414,7 @@ namespace System.Web.UI.WebControls { c.ID = wc.ClientID; c.CopyBaseAttributes (wc); c.ApplyStyle (s); - c.Enabled = wc.Enabled; + c.Enabled = wc.IsEnabled; c.RenderBeginTag (w); } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Repeater.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Repeater.cs index e99f1ede0d1..499143e7e6e 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/Repeater.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/Repeater.cs @@ -533,10 +533,11 @@ namespace System.Web.UI.WebControls { protected internal override void OnInit (EventArgs e) { base.OnInit (e); - if (Page != null) { - Page.PreLoad += new EventHandler (OnPagePreLoad); + Page page = Page; + if (page != null) { + page.PreLoad += new EventHandler (OnPagePreLoad); - if (!IsViewStateEnabled && Page.IsPostBack) + if (!IsViewStateEnabled && page.IsPostBack) RequiresDataBinding = true; } } @@ -556,8 +557,9 @@ namespace System.Web.UI.WebControls { void Initialize () { - if (Page != null) { - if (!Page.IsPostBack || (IsViewStateEnabled && (ViewState ["Items"] == null))) + Page page = Page; + if (page != null) { + if (!page.IsPostBack || (IsViewStateEnabled && (ViewState ["Items"] == null))) RequiresDataBinding = true; } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs index d072f9a42c8..f1b447e85d0 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/TextBox.cs @@ -195,7 +195,7 @@ namespace System.Web.UI.WebControls { } Page page = Page; - if (page != null && Enabled) + if (page != null && IsEnabled) page.RegisterEnabledControl (this); #endif } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs b/mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs index 29045654e93..910669704d2 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/TreeView.cs @@ -1086,13 +1086,14 @@ namespace System.Web.UI.WebControls { base.OnPreRender (e); - if (Page != null) { - if (Enabled) - Page.RegisterRequiresPostBack (this); + Page page = Page; + if (page != null) { + if (IsEnabled) + page.RegisterRequiresPostBack (this); - if (EnableClientScript && !Page.ClientScript.IsClientScriptIncludeRegistered (typeof(TreeView), "TreeView.js")) { - string url = Page.ClientScript.GetWebResourceUrl (typeof(TreeView), "TreeView.js"); - Page.ClientScript.RegisterClientScriptInclude (typeof(TreeView), "TreeView.js", url); + if (EnableClientScript && !page.ClientScript.IsClientScriptIncludeRegistered (typeof(TreeView), "TreeView.js")) { + string url = page.ClientScript.GetWebResourceUrl (typeof(TreeView), "TreeView.js"); + page.ClientScript.RegisterClientScriptInclude (typeof(TreeView), "TreeView.js", url); } } @@ -1117,11 +1118,11 @@ namespace System.Web.UI.WebControls ClientScriptManager.GetScriptLiteral (GetNodeImageUrl ("noexpand", imageStyle))); } - if (Page != null) { + if (page != null) { script.AppendFormat (_OnPreRender_Script_PopulateCallback, ctree, - Page.theForm, - Page.WebFormScriptReference); + page.theForm, + page.WebFormScriptReference); // Page.ClientScript.GetCallbackEventReference ( // "this.uid", "nodeId", @@ -1134,23 +1135,24 @@ namespace System.Web.UI.WebControls ClientScriptManager.GetScriptLiteral (GetNodeImageToolTip (true, null)), ClientScriptManager.GetScriptLiteral (GetNodeImageToolTip (false, null))); - if (!Page.IsPostBack) + if (!page.IsPostBack) SetNodesExpandedToDepthRecursive (Nodes); - if (EnableClientScript) { - Page.ClientScript.RegisterHiddenField (ClientID + "_ExpandStates", GetExpandStates ()); + bool enableClientScript = EnableClientScript; + if (enableClientScript) { + page.ClientScript.RegisterHiddenField (ClientID + "_ExpandStates", GetExpandStates ()); // Make sure the basic script infrastructure is rendered - Page.ClientScript.RegisterWebFormClientScript (); + page.ClientScript.RegisterWebFormClientScript (); } - if (EnableClientScript && PopulateNodesFromClient) - Page.ClientScript.RegisterHiddenField (ClientID + "_PopulatedStates", "|"); + if (enableClientScript && PopulateNodesFromClient) + page.ClientScript.RegisterHiddenField (ClientID + "_PopulatedStates", "|"); EnsureStylesPrepared (); if (hoverNodeStyle != null) { - if (Page.Header == null) + if (page.Header == null) throw new InvalidOperationException ("Using TreeView.HoverNodeStyle requires Page.Header to be non-null (e.g. <head runat=\"server\" />)."); RegisterStyle (HoverNodeStyle, HoverNodeLinkStyle); script.AppendFormat (_OnPreRender_Script_HoverStyle, @@ -1159,7 +1161,7 @@ namespace System.Web.UI.WebControls ClientScriptManager.GetScriptLiteral (HoverNodeLinkStyle.RegisteredCssClass)); } - Page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script.ToString (), true); + page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script.ToString (), true); script = null; } } diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs index 10d084495f7..7b86d1347a6 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ValidationSummary.cs @@ -242,7 +242,7 @@ namespace System.Web.UI.WebControls { #endif override void Render(HtmlTextWriter writer) { #if NET_2_0 - if (!Enabled) + if (!IsEnabled) return; #endif ValidatorCollection validators; diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs b/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs index 0ea00fac0a5..fc6f2b8782d 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs @@ -408,9 +408,12 @@ namespace System.Web.UI.WebControls { } #if NET_2_0 - protected internal bool IsEnabled + protected +#endif + internal bool IsEnabled { get { +#if NET_2_0 WebControl wc = this; while (wc != null) { if (!wc.Enabled) @@ -418,10 +421,11 @@ namespace System.Web.UI.WebControls { wc = wc.Parent as WebControl; } return true; +#else + return Enabled; +#endif } } -#endif - public void ApplyStyle (Style s) { @@ -519,7 +523,7 @@ namespace System.Web.UI.WebControls { if (AccessKey != string.Empty) writer.AddAttribute (HtmlTextWriterAttribute.Accesskey, AccessKey); - if (!enabled) + if (!IsEnabled) writer.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled", false); if (ToolTip != string.Empty) |