diff options
Diffstat (limited to 'mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs')
-rw-r--r-- | mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs | 312 |
1 files changed, 144 insertions, 168 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs index 296a1191ac2..38fafe7a75d 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/DetailsView.cs @@ -40,14 +40,13 @@ using System.Reflection; namespace System.Web.UI.WebControls { - [SupportsEventValidation] [ToolboxDataAttribute ("<{0}:DetailsView runat=\"server\" Width=\"125px\" Height=\"50px\"></{0}:DetailsView>")]
[DesignerAttribute ("System.Web.UI.Design.WebControls.DetailsViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")] [ControlValuePropertyAttribute ("SelectedValue")] [DefaultEventAttribute ("PageIndexChanging")] [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] - public class DetailsView: CompositeDataBoundControl, ICallbackEventHandler, ICallbackContainer, IDataItemContainer, INamingContainer, IPostBackEventHandler, IPostBackContainer + public class DetailsView: CompositeDataBoundControl, ICallbackEventHandler, ICallbackContainer, IDataItemContainer, INamingContainer { object dataItem; @@ -273,7 +272,7 @@ namespace System.Web.UI.WebControls [WebCategoryAttribute ("Paging")] [DefaultValueAttribute (false)] - public virtual bool AllowPaging { + public bool AllowPaging { get { object ob = ViewState ["AllowPaging"]; if (ob != null) return (bool) ob; @@ -286,11 +285,11 @@ namespace System.Web.UI.WebControls } [DefaultValueAttribute (null)] - [WebCategoryAttribute ("Styles")] + [WebCategoryAttribute ("Styles")] [PersistenceMode (PersistenceMode.InnerProperty)] [NotifyParentProperty (true)] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] - public TableItemStyle AlternatingRowStyle { + public virtual TableItemStyle AlternatingRowStyle { get { if (alternatingRowStyle == null) { alternatingRowStyle = new TableItemStyle (); @@ -385,7 +384,7 @@ namespace System.Web.UI.WebControls [WebCategoryAttribute ("Accessibility")] [DefaultValueAttribute ("")] [LocalizableAttribute (true)] - public virtual string Caption { + public string Caption { get { object ob = ViewState ["Caption"]; if (ob != null) return (string) ob; @@ -443,11 +442,11 @@ namespace System.Web.UI.WebControls } [DefaultValueAttribute (null)] - [WebCategoryAttribute ("Styles")] + [WebCategoryAttribute ("Styles")] [PersistenceMode (PersistenceMode.InnerProperty)] [NotifyParentProperty (true)] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] - public TableItemStyle CommandRowStyle { + public virtual TableItemStyle CommandRowStyle { get { if (commandRowStyle == null) { commandRowStyle = new TableItemStyle (); @@ -458,16 +457,16 @@ namespace System.Web.UI.WebControls } } - [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- [BrowsableAttribute (false)]
+ [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
+ [BrowsableAttribute (false)]
public DetailsViewMode CurrentMode { get { return currentMode; } } - [DefaultValueAttribute (DetailsViewMode.ReadOnly)]
- [WebCategoryAttribute ("Behavior")]
+ [DefaultValueAttribute (DetailsViewMode.ReadOnly)]
+ [WebCategoryAttribute ("Behavior")]
public virtual DetailsViewMode DefaultMode { get { object o = ViewState ["DefaultMode"]; @@ -523,12 +522,12 @@ namespace System.Web.UI.WebControls } } - [WebCategoryAttribute ("Styles")] + [WebCategoryAttribute ("Styles")] [PersistenceMode (PersistenceMode.InnerProperty)] [NotifyParentProperty (true)] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] - [DefaultValueAttribute (null)]
- public TableItemStyle EditRowStyle { + [DefaultValueAttribute (null)]
+ public virtual TableItemStyle EditRowStyle { get { if (editRowStyle == null) { editRowStyle = new TableItemStyle (); @@ -539,12 +538,12 @@ namespace System.Web.UI.WebControls } } - [WebCategoryAttribute ("Styles")] + [WebCategoryAttribute ("Styles")] [PersistenceMode (PersistenceMode.InnerProperty)] [NotifyParentProperty (true)] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] - [DefaultValueAttribute (null)]
- public TableItemStyle EmptyDataRowStyle { + [DefaultValueAttribute (null)]
+ public virtual TableItemStyle EmptyDataRowStyle { get { if (emptyDataRowStyle == null) { emptyDataRowStyle = new TableItemStyle (); @@ -558,8 +557,8 @@ namespace System.Web.UI.WebControls [DefaultValue (null)] [TemplateContainer (typeof(DetailsView), BindingDirection.OneWay)] [PersistenceMode (PersistenceMode.InnerProperty)] - [Browsable (false)] - public virtual ITemplate EmptyDataTemplate { + [Browsable (false)] + public ITemplate EmptyDataTemplate { get { return emptyDataTemplate; } set { emptyDataTemplate = value; RequireBinding (); } } @@ -593,12 +592,12 @@ namespace System.Web.UI.WebControls } } - [WebCategoryAttribute ("Styles")] + [WebCategoryAttribute ("Styles")] [PersistenceMode (PersistenceMode.InnerProperty)] [NotifyParentProperty (true)] [DefaultValue (null)] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] - public TableItemStyle FieldHeaderStyle { + public virtual TableItemStyle FieldHeaderStyle { get { if (fieldHeaderStyle == null) { fieldHeaderStyle = new TableItemStyle (); @@ -621,16 +620,16 @@ namespace System.Web.UI.WebControls [DefaultValue (null)] [TemplateContainer (typeof(DetailsView), BindingDirection.OneWay)] [PersistenceMode (PersistenceMode.InnerProperty)] - [Browsable (false)] - public virtual ITemplate FooterTemplate { + [Browsable (false)] + public ITemplate FooterTemplate { get { return footerTemplate; } set { footerTemplate = value; RequireBinding (); } } - [LocalizableAttribute (true)]
- [WebCategoryAttribute ("Appearance")]
- [DefaultValueAttribute ("")]
- public virtual string FooterText { + [LocalizableAttribute (true)]
+ [WebCategoryAttribute ("Appearance")]
+ [DefaultValueAttribute ("")]
+ public string FooterText { get { object ob = ViewState ["FooterText"]; if (ob != null) return (string) ob; @@ -642,12 +641,12 @@ namespace System.Web.UI.WebControls } } - [WebCategoryAttribute ("Styles")] + [WebCategoryAttribute ("Styles")] [PersistenceMode (PersistenceMode.InnerProperty)] [NotifyParentProperty (true)] [DefaultValue (null)] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] - public TableItemStyle FooterStyle { + public virtual TableItemStyle FooterStyle { get { if (footerStyle == null) { footerStyle = new TableItemStyle (); @@ -680,12 +679,12 @@ namespace System.Web.UI.WebControls } } - [WebCategoryAttribute ("Styles")] + [WebCategoryAttribute ("Styles")] [PersistenceMode (PersistenceMode.InnerProperty)] [NotifyParentProperty (true)] [DefaultValue (null)] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] - public TableItemStyle HeaderStyle { + public virtual TableItemStyle HeaderStyle { get { if (headerStyle == null) { headerStyle = new TableItemStyle (); @@ -699,16 +698,16 @@ namespace System.Web.UI.WebControls [DefaultValue (null)] [TemplateContainer (typeof(DetailsView), BindingDirection.OneWay)] [PersistenceMode (PersistenceMode.InnerProperty)] - [Browsable (false)] - public virtual ITemplate HeaderTemplate { + [Browsable (false)] + public ITemplate HeaderTemplate { get { return headerTemplate; } set { headerTemplate = value; RequireBinding (); } } - [LocalizableAttribute (true)]
- [WebCategoryAttribute ("Appearance")]
- [DefaultValueAttribute ("")]
- public virtual string HeaderText { + [LocalizableAttribute (true)]
+ [WebCategoryAttribute ("Appearance")]
+ [DefaultValueAttribute ("")]
+ public string HeaderText { get { object ob = ViewState ["HeaderText"]; if (ob != null) return (string) ob; @@ -734,12 +733,12 @@ namespace System.Web.UI.WebControls } } - [WebCategoryAttribute ("Styles")] + [WebCategoryAttribute ("Styles")] [PersistenceMode (PersistenceMode.InnerProperty)] [NotifyParentProperty (true)] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] - [DefaultValueAttribute (null)]
- public TableItemStyle InsertRowStyle { + [DefaultValueAttribute (null)]
+ public virtual TableItemStyle InsertRowStyle { get { if (insertRowStyle == null) { insertRowStyle = new TableItemStyle (); @@ -752,7 +751,7 @@ namespace System.Web.UI.WebControls [BrowsableAttribute (false)] [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)] - public virtual int PageCount { + public int PageCount { get { if (pageCount != -1) return pageCount; EnsureDataBound (); @@ -761,9 +760,9 @@ namespace System.Web.UI.WebControls } [WebCategoryAttribute ("Paging")] - [BindableAttribute (true, BindingDirection.OneWay)]
+ [BindableAttribute (true, BindingDirection.OneWay)]
[DefaultValueAttribute (0)] - public virtual int PageIndex { + public int PageIndex { get { return pageIndex; } @@ -777,7 +776,7 @@ namespace System.Web.UI.WebControls [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)] [NotifyParentPropertyAttribute (true)] [PersistenceModeAttribute (PersistenceMode.InnerProperty)] - public virtual PagerSettings PagerSettings { + public PagerSettings PagerSettings { get { if (pagerSettings == null) { pagerSettings = new PagerSettings (this); @@ -788,11 +787,11 @@ namespace System.Web.UI.WebControls } } - [WebCategoryAttribute ("Styles")] + [WebCategoryAttribute ("Styles")] [PersistenceMode (PersistenceMode.InnerProperty)] [NotifyParentProperty (true)] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] - public TableItemStyle PagerStyle { + public virtual TableItemStyle PagerStyle { get { if (pagerStyle == null) { pagerStyle = new TableItemStyle (); @@ -808,8 +807,8 @@ namespace System.Web.UI.WebControls /* DataControlPagerCell isnt specified in the docs */ //[TemplateContainer (typeof(DataControlPagerCell), BindingDirection.OneWay)] [PersistenceMode (PersistenceMode.InnerProperty)] - [Browsable (false)] - public virtual ITemplate PagerTemplate { + [Browsable (false)] + public ITemplate PagerTemplate { get { return pagerTemplate; } set { pagerTemplate = value; RequireBinding (); } } @@ -823,12 +822,12 @@ namespace System.Web.UI.WebControls } } - [WebCategoryAttribute ("Styles")] + [WebCategoryAttribute ("Styles")] [PersistenceMode (PersistenceMode.InnerProperty)] [NotifyParentProperty (true)] [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)] [DefaultValue (null)] - public TableItemStyle RowStyle { + public virtual TableItemStyle RowStyle { get { if (rowStyle == null) { rowStyle = new TableItemStyle (); @@ -839,9 +838,9 @@ namespace System.Web.UI.WebControls } } - [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
+ [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
[BrowsableAttribute (false)] - public object SelectedValue { + public virtual object SelectedValue { get { return DataKey.Value; } } @@ -856,7 +855,7 @@ namespace System.Web.UI.WebControls [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)] [BrowsableAttribute (false)] - public virtual object DataItem { + public object DataItem { get { EnsureDataBound (); return dataItem; @@ -871,7 +870,7 @@ namespace System.Web.UI.WebControls [DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)] [BrowsableAttribute (false)] - public virtual int DataItemIndex { + public int DataItemIndex { get { return PageIndex; } } @@ -1292,12 +1291,7 @@ namespace System.Web.UI.WebControls } return base.OnBubbleEvent (source, e); } - - void IPostBackEventHandler.RaisePostBackEvent (string eventArgument) - { - RaisePostBackEvent (eventArgument); - } - + // TODO: This is prolly obsolete protected virtual void RaisePostBackEvent (string eventArgument) { @@ -1312,69 +1306,69 @@ namespace System.Web.UI.WebControls { switch (eventName) { - case DataControlCommands.PageCommandName: - int newIndex = -1; - switch (param) { + case DataControlCommands.PageCommandName: + int newIndex = -1; + switch (param) { + case DataControlCommands.FirstPageCommandArgument: + newIndex = 0; + break; + case DataControlCommands.LastPageCommandArgument: + newIndex = PageCount - 1; + break; + case DataControlCommands.NextPageCommandArgument: + if (PageIndex < PageCount - 1) newIndex = PageIndex + 1; + break; + case DataControlCommands.PreviousPageCommandArgument: + if (PageIndex > 0) newIndex = PageIndex - 1; + break; + default: + newIndex = int.Parse (param) - 1; + break; + } + ShowPage (newIndex); + break; + case DataControlCommands.FirstPageCommandArgument: - newIndex = 0; + ShowPage (0); break; + case DataControlCommands.LastPageCommandArgument: - newIndex = PageCount - 1; + ShowPage (PageCount - 1); break; + case DataControlCommands.NextPageCommandArgument: - if (PageIndex < PageCount - 1) newIndex = PageIndex + 1; + if (PageIndex < PageCount - 1) + ShowPage (PageIndex + 1); break; + case DataControlCommands.PreviousPageCommandArgument: - if (PageIndex > 0) newIndex = PageIndex - 1; - break; - default: - newIndex = int.Parse (param) - 1; + if (PageIndex > 0) + ShowPage (PageIndex - 1); break; - } - ShowPage (newIndex); - break; - - case DataControlCommands.FirstPageCommandArgument: - ShowPage (0); - break; - - case DataControlCommands.LastPageCommandArgument: - ShowPage (PageCount - 1); - break; - - case DataControlCommands.NextPageCommandArgument: - if (PageIndex < PageCount - 1) - ShowPage (PageIndex + 1); - break; - - case DataControlCommands.PreviousPageCommandArgument: - if (PageIndex > 0) - ShowPage (PageIndex - 1); - break; - case DataControlCommands.EditCommandName: - ChangeMode (DetailsViewMode.Edit); - break; + case DataControlCommands.EditCommandName: + ChangeMode (DetailsViewMode.Edit); + break; - case DataControlCommands.NewCommandName: - ChangeMode (DetailsViewMode.Insert); - break; + case DataControlCommands.NewCommandName: + ChangeMode (DetailsViewMode.Insert); + break; - case DataControlCommands.UpdateCommandName: - UpdateItem (param, true); - break; + case DataControlCommands.UpdateCommandName: + UpdateItem (param, true); + break; - case DataControlCommands.CancelCommandName: - CancelEdit (); - break; + case DataControlCommands.CancelCommandName: + CancelEdit (); + break; - case DataControlCommands.DeleteCommandName: - DeleteItem (); - break; + case DataControlCommands.DeleteCommandName: + DeleteItem (); + break; - case DataControlCommands.InsertCommandName: - InsertItem (true); - break; + case DataControlCommands.InsertCommandName: + InsertItem (true); + break; } } @@ -1436,7 +1430,7 @@ namespace System.Web.UI.WebControls EndRowEdit (); } - bool UpdateCallback (int recordsAffected, Exception exception) + bool UpdateCallback (int recordsAffected, Exception exception) { DetailsViewUpdatedEventArgs dargs = new DetailsViewUpdatedEventArgs (recordsAffected, exception, currentEditRowKeys, currentEditOldValues, currentEditNewValues); OnItemUpdated (dargs); @@ -1470,7 +1464,7 @@ namespace System.Web.UI.WebControls EndRowEdit (); } - bool InsertCallback (int recordsAffected, Exception exception) + bool InsertCallback (int recordsAffected, Exception exception) { DetailsViewInsertedEventArgs dargs = new DetailsViewInsertedEventArgs (recordsAffected, exception, currentEditNewValues); OnItemInserted (dargs); @@ -1481,7 +1475,7 @@ namespace System.Web.UI.WebControls return dargs.ExceptionHandled; } - public virtual void DeleteItem () + public void DeleteItem () { currentEditRowKeys = DataKey.Values; currentEditNewValues = GetRowValues (true, true); @@ -1503,7 +1497,7 @@ namespace System.Web.UI.WebControls } } - bool DeleteCallback (int recordsAffected, Exception exception) + bool DeleteCallback (int recordsAffected, Exception exception) { DetailsViewDeletedEventArgs dargs = new DetailsViewDeletedEventArgs (recordsAffected, exception, currentEditRowKeys, currentEditNewValues); OnItemDeleted (dargs); @@ -1535,7 +1529,7 @@ namespace System.Web.UI.WebControls object bstate = base.SaveControlState (); return new object[] { bstate, pageIndex, pageCount, currentMode - }; + }; } protected override void TrackViewState() @@ -1630,13 +1624,12 @@ namespace System.Web.UI.WebControls if (states[12] != null && oldEditValues != null) ((IStateManager)oldEditValues).LoadViewState (states[12]); } - void ICallbackEventHandler.RaiseCallbackEvent (string eventArgs) + string ICallbackEventHandler.RaiseCallbackEvent (string eventArgs) { - RaiseCallbackEvent (eventArgs); + return RaiseCallbackEvent (eventArgs); } - string callbackResult; - protected virtual void RaiseCallbackEvent (string eventArgs) + protected virtual string RaiseCallbackEvent (string eventArgs) { string[] clientData = eventArgs.Split ('|'); pageIndex = int.Parse (clientData[0]); @@ -1650,17 +1643,7 @@ namespace System.Web.UI.WebControls HtmlTextWriter writer = new HtmlTextWriter (sw); RenderGrid (writer); - callbackResult = sw.ToString (); - } - - string ICallbackEventHandler.GetCallbackResult () - { - return GetCallbackResult (); - } - - protected virtual string GetCallbackResult () - { - return callbackResult; + return sw.ToString (); } [MonoTODO] @@ -1701,7 +1684,7 @@ namespace System.Web.UI.WebControls Page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script, true); // Make sure the basic script infrastructure is rendered - Page.ClientScript.GetCallbackEventReference (this, "null", "", "null"); + Page.ClientScript.GetCallbackEventReference (this, "null", "", "null"); Page.ClientScript.GetPostBackClientHyperlink (this, ""); } } @@ -1720,21 +1703,21 @@ namespace System.Web.UI.WebControls void RenderGrid (HtmlTextWriter writer) { switch (GridLines) { - case GridLines.Horizontal: - writer.AddAttribute (HtmlTextWriterAttribute.Rules, "rows"); - writer.AddAttribute (HtmlTextWriterAttribute.Border, "1"); - break; - case GridLines.Vertical: - writer.AddAttribute (HtmlTextWriterAttribute.Rules, "cols"); - writer.AddAttribute (HtmlTextWriterAttribute.Border, "1"); - break; - case GridLines.Both: - writer.AddAttribute (HtmlTextWriterAttribute.Rules, "all"); - writer.AddAttribute (HtmlTextWriterAttribute.Border, "1"); - break; - default: - writer.AddAttribute (HtmlTextWriterAttribute.Border, "0"); - break; + case GridLines.Horizontal: + writer.AddAttribute (HtmlTextWriterAttribute.Rules, "rows"); + writer.AddAttribute (HtmlTextWriterAttribute.Border, "1"); + break; + case GridLines.Vertical: + writer.AddAttribute (HtmlTextWriterAttribute.Rules, "cols"); + writer.AddAttribute (HtmlTextWriterAttribute.Border, "1"); + break; + case GridLines.Both: + writer.AddAttribute (HtmlTextWriterAttribute.Rules, "all"); + writer.AddAttribute (HtmlTextWriterAttribute.Border, "1"); + break; + default: + writer.AddAttribute (HtmlTextWriterAttribute.Border, "0"); + break; } writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0"); @@ -1744,21 +1727,21 @@ namespace System.Web.UI.WebControls foreach (DetailsViewRow row in table.Rows) { switch (row.RowType) { - case DataControlRowType.Header: - if (headerStyle != null)headerStyle.AddAttributesToRender (writer, row); - break; - case DataControlRowType.Footer: - if (footerStyle != null) footerStyle.AddAttributesToRender (writer, row); - break; - case DataControlRowType.Pager: - if (pagerStyle != null) pagerStyle.AddAttributesToRender (writer, row); - break; - case DataControlRowType.EmptyDataRow: - if (emptyDataRowStyle != null) emptyDataRowStyle.AddAttributesToRender (writer, row); - break; - default: - if (rowStyle != null) rowStyle.AddAttributesToRender (writer, row); - break; + case DataControlRowType.Header: + if (headerStyle != null)headerStyle.AddAttributesToRender (writer, row); + break; + case DataControlRowType.Footer: + if (footerStyle != null) footerStyle.AddAttributesToRender (writer, row); + break; + case DataControlRowType.Pager: + if (pagerStyle != null) pagerStyle.AddAttributesToRender (writer, row); + break; + case DataControlRowType.EmptyDataRow: + if (emptyDataRowStyle != null) emptyDataRowStyle.AddAttributesToRender (writer, row); + break; + default: + if (rowStyle != null) rowStyle.AddAttributesToRender (writer, row); + break; } if ((row.RowState & DataControlRowState.Alternate) != 0 && alternatingRowStyle != null) @@ -1790,13 +1773,6 @@ namespace System.Web.UI.WebControls } table.RenderEndTag (writer); } - - - [MonoTODO] - PostBackOptions IPostBackContainer.GetPostBackOptions (IButtonControl control) - { - throw new NotImplementedException (); - } } } |