Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / WebControls / TableCell.cs / 2 / TableCell.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Collections; using System.Globalization; using System.ComponentModel; using System.ComponentModel.Design; using System.Text; using System.Web; using System.Web.UI; using System.Security.Permissions; ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class TableCellControlBuilder : ControlBuilder { ///Interacts with the parser to build a ///control. /// /// Specifies whether white space literals are allowed. /// public override bool AllowWhitespaceLiterals() { return false; } } ////// [ Bindable(false), ControlBuilderAttribute(typeof(TableCellControlBuilder)), DefaultProperty("Text"), ParseChildren(false), ToolboxItem(false) ] [Designer("System.Web.UI.Design.WebControls.PreviewControlDesigner, " + AssemblyRef.SystemDesign)] [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class TableCell : WebControl { private bool _textSetByAddParsedSubObject = false; ///Encapsulates a cell within a table. ////// public TableCell() : this(HtmlTextWriterTag.Td) { } ////// Initializes a new instance of the ///class. /// /// internal TableCell(HtmlTextWriterTag tagKey) : base(tagKey) { PreventAutoID(); } ////// [ DefaultValue(null), TypeConverterAttribute(typeof(StringArrayConverter)), WebCategory("Accessibility"), WebSysDescription(SR.TableCell_AssociatedHeaderCellID) ] public virtual string[] AssociatedHeaderCellID { get { object x = ViewState["AssociatedHeaderCellID"]; return (x != null) ? (string[])((string[])x).Clone() : new string[0]; } set { if (value != null) { ViewState["AssociatedHeaderCellID"] = (string[])value.Clone(); } else { ViewState["AssociatedHeaderCellID"] = null; } } } ////// Contains a list of categories associated with the table header (read by screen readers). The categories can be any string values. The categories are rendered as a comma delimited list using the HTML axis attribute. /// ////// [ WebCategory("Appearance"), DefaultValue(0), WebSysDescription(SR.TableCell_ColumnSpan) ] public virtual int ColumnSpan { get { object o = ViewState["ColumnSpan"]; return((o == null) ? 0 : (int)o); } set { if (value < 0) { throw new ArgumentOutOfRangeException("value"); } ViewState["ColumnSpan"] = value; } } ///Gets or sets the number /// of columns this table cell stretches horizontally. ////// [ WebCategory("Layout"), DefaultValue(HorizontalAlign.NotSet), WebSysDescription(SR.TableItem_HorizontalAlign) ] public virtual HorizontalAlign HorizontalAlign { get { if (ControlStyleCreated == false) { return HorizontalAlign.NotSet; } return ((TableItemStyle)ControlStyle).HorizontalAlign; } set { ((TableItemStyle)ControlStyle).HorizontalAlign = value; } } ///Gets or sets /// the horizontal alignment of the content within the cell. ////// [ WebCategory("Layout"), DefaultValue(0), WebSysDescription(SR.TableCell_RowSpan) ] public virtual int RowSpan { get { object o = ViewState["RowSpan"]; return((o == null) ? 0 : (int)o); } set { if (value < 0) { throw new ArgumentOutOfRangeException("value"); } ViewState["RowSpan"] = value; } } ///Gets or sets the /// number of rows this table cell stretches vertically. ////// [ Localizable(true), WebCategory("Appearance"), DefaultValue(""), PersistenceMode(PersistenceMode.InnerDefaultProperty), WebSysDescription(SR.TableCell_Text) ] public virtual string Text { get { object o = ViewState["Text"]; return((o == null) ? String.Empty : (string)o); } set { if (HasControls()) { Controls.Clear(); } ViewState["Text"] = value; } } ///Gets /// or sets the text contained in the cell. ////// [ WebCategory("Layout"), DefaultValue(VerticalAlign.NotSet), WebSysDescription(SR.TableItem_VerticalAlign) ] public virtual VerticalAlign VerticalAlign { get { if (ControlStyleCreated == false) { return VerticalAlign.NotSet; } return ((TableItemStyle)ControlStyle).VerticalAlign; } set { ((TableItemStyle)ControlStyle).VerticalAlign = value; } } ///Gets or sets the vertical alignment of the content within the cell. ////// [ WebCategory("Layout"), DefaultValue(true), WebSysDescription(SR.TableCell_Wrap) ] public virtual bool Wrap { get { if (ControlStyleCreated == false) { return true; } return ((TableItemStyle)ControlStyle).Wrap; } set { ((TableItemStyle)ControlStyle).Wrap = value; } } ////// Gets or sets /// whether the cell content wraps within the cell. /// ////// /// protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); int span = ColumnSpan; if (span > 0) writer.AddAttribute(HtmlTextWriterAttribute.Colspan, span.ToString(NumberFormatInfo.InvariantInfo)); span = RowSpan; if (span > 0) writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, span.ToString(NumberFormatInfo.InvariantInfo)); string[] arr = AssociatedHeaderCellID; if (arr.Length > 0) { bool first = true; StringBuilder builder = new StringBuilder(); Control namingContainer = NamingContainer; foreach (string id in arr) { TableHeaderCell headerCell = namingContainer.FindControl(id) as TableHeaderCell; if (headerCell == null) { throw new HttpException(SR.GetString(SR.TableCell_AssociatedHeaderCellNotFound, id)); } if (first) { first = false; } else { // AssociatedHeaderCellID was seperated by "," instead of " ". (DevDiv Bugs 159670) builder.Append(" "); } builder.Append(headerCell.ClientID); } string val = builder.ToString(); if (!String.IsNullOrEmpty(val)) { writer.AddAttribute(HtmlTextWriterAttribute.Headers, val); } } } ///A protected method. Adds information about the column /// span and row span to the list of attributes to render. ////// protected override void AddParsedSubObject(object obj) { if (HasControls()) { base.AddParsedSubObject(obj); } else { if (obj is LiteralControl) { // If we have multiple LiteralControls added here (as would happen if there were a code block // at design time) we don't want to overwrite Text with the last LiteralControl's Text. Just // concatenate their content. However, if Text was set by the property or was in ViewState, // we want to overwrite it. if (_textSetByAddParsedSubObject) { Text += ((LiteralControl)obj).Text; } else { Text = ((LiteralControl)obj).Text; } _textSetByAddParsedSubObject = true; } else { string currentText = Text; if (currentText.Length != 0) { Text = String.Empty; base.AddParsedSubObject(new LiteralControl(currentText)); } base.AddParsedSubObject(obj); } } } ////// /// protected override Style CreateControlStyle() { return new TableItemStyle(ViewState); } ///A protected /// method. Creates a table item control /// style. ////// /// protected internal override void RenderContents(HtmlTextWriter writer) { // We can't use HasControls() here, because we may have a compiled render method (ASURT 94127) if (HasRenderingData()) { base.RenderContents(writer); } else { writer.Write(Text); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------------ //A protected method. ///// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System; using System.Collections; using System.Globalization; using System.ComponentModel; using System.ComponentModel.Design; using System.Text; using System.Web; using System.Web.UI; using System.Security.Permissions; ////// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class TableCellControlBuilder : ControlBuilder { ///Interacts with the parser to build a ///control. /// /// Specifies whether white space literals are allowed. /// public override bool AllowWhitespaceLiterals() { return false; } } ////// [ Bindable(false), ControlBuilderAttribute(typeof(TableCellControlBuilder)), DefaultProperty("Text"), ParseChildren(false), ToolboxItem(false) ] [Designer("System.Web.UI.Design.WebControls.PreviewControlDesigner, " + AssemblyRef.SystemDesign)] [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class TableCell : WebControl { private bool _textSetByAddParsedSubObject = false; ///Encapsulates a cell within a table. ////// public TableCell() : this(HtmlTextWriterTag.Td) { } ////// Initializes a new instance of the ///class. /// /// internal TableCell(HtmlTextWriterTag tagKey) : base(tagKey) { PreventAutoID(); } ////// [ DefaultValue(null), TypeConverterAttribute(typeof(StringArrayConverter)), WebCategory("Accessibility"), WebSysDescription(SR.TableCell_AssociatedHeaderCellID) ] public virtual string[] AssociatedHeaderCellID { get { object x = ViewState["AssociatedHeaderCellID"]; return (x != null) ? (string[])((string[])x).Clone() : new string[0]; } set { if (value != null) { ViewState["AssociatedHeaderCellID"] = (string[])value.Clone(); } else { ViewState["AssociatedHeaderCellID"] = null; } } } ////// Contains a list of categories associated with the table header (read by screen readers). The categories can be any string values. The categories are rendered as a comma delimited list using the HTML axis attribute. /// ////// [ WebCategory("Appearance"), DefaultValue(0), WebSysDescription(SR.TableCell_ColumnSpan) ] public virtual int ColumnSpan { get { object o = ViewState["ColumnSpan"]; return((o == null) ? 0 : (int)o); } set { if (value < 0) { throw new ArgumentOutOfRangeException("value"); } ViewState["ColumnSpan"] = value; } } ///Gets or sets the number /// of columns this table cell stretches horizontally. ////// [ WebCategory("Layout"), DefaultValue(HorizontalAlign.NotSet), WebSysDescription(SR.TableItem_HorizontalAlign) ] public virtual HorizontalAlign HorizontalAlign { get { if (ControlStyleCreated == false) { return HorizontalAlign.NotSet; } return ((TableItemStyle)ControlStyle).HorizontalAlign; } set { ((TableItemStyle)ControlStyle).HorizontalAlign = value; } } ///Gets or sets /// the horizontal alignment of the content within the cell. ////// [ WebCategory("Layout"), DefaultValue(0), WebSysDescription(SR.TableCell_RowSpan) ] public virtual int RowSpan { get { object o = ViewState["RowSpan"]; return((o == null) ? 0 : (int)o); } set { if (value < 0) { throw new ArgumentOutOfRangeException("value"); } ViewState["RowSpan"] = value; } } ///Gets or sets the /// number of rows this table cell stretches vertically. ////// [ Localizable(true), WebCategory("Appearance"), DefaultValue(""), PersistenceMode(PersistenceMode.InnerDefaultProperty), WebSysDescription(SR.TableCell_Text) ] public virtual string Text { get { object o = ViewState["Text"]; return((o == null) ? String.Empty : (string)o); } set { if (HasControls()) { Controls.Clear(); } ViewState["Text"] = value; } } ///Gets /// or sets the text contained in the cell. ////// [ WebCategory("Layout"), DefaultValue(VerticalAlign.NotSet), WebSysDescription(SR.TableItem_VerticalAlign) ] public virtual VerticalAlign VerticalAlign { get { if (ControlStyleCreated == false) { return VerticalAlign.NotSet; } return ((TableItemStyle)ControlStyle).VerticalAlign; } set { ((TableItemStyle)ControlStyle).VerticalAlign = value; } } ///Gets or sets the vertical alignment of the content within the cell. ////// [ WebCategory("Layout"), DefaultValue(true), WebSysDescription(SR.TableCell_Wrap) ] public virtual bool Wrap { get { if (ControlStyleCreated == false) { return true; } return ((TableItemStyle)ControlStyle).Wrap; } set { ((TableItemStyle)ControlStyle).Wrap = value; } } ////// Gets or sets /// whether the cell content wraps within the cell. /// ////// /// protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); int span = ColumnSpan; if (span > 0) writer.AddAttribute(HtmlTextWriterAttribute.Colspan, span.ToString(NumberFormatInfo.InvariantInfo)); span = RowSpan; if (span > 0) writer.AddAttribute(HtmlTextWriterAttribute.Rowspan, span.ToString(NumberFormatInfo.InvariantInfo)); string[] arr = AssociatedHeaderCellID; if (arr.Length > 0) { bool first = true; StringBuilder builder = new StringBuilder(); Control namingContainer = NamingContainer; foreach (string id in arr) { TableHeaderCell headerCell = namingContainer.FindControl(id) as TableHeaderCell; if (headerCell == null) { throw new HttpException(SR.GetString(SR.TableCell_AssociatedHeaderCellNotFound, id)); } if (first) { first = false; } else { // AssociatedHeaderCellID was seperated by "," instead of " ". (DevDiv Bugs 159670) builder.Append(" "); } builder.Append(headerCell.ClientID); } string val = builder.ToString(); if (!String.IsNullOrEmpty(val)) { writer.AddAttribute(HtmlTextWriterAttribute.Headers, val); } } } ///A protected method. Adds information about the column /// span and row span to the list of attributes to render. ////// protected override void AddParsedSubObject(object obj) { if (HasControls()) { base.AddParsedSubObject(obj); } else { if (obj is LiteralControl) { // If we have multiple LiteralControls added here (as would happen if there were a code block // at design time) we don't want to overwrite Text with the last LiteralControl's Text. Just // concatenate their content. However, if Text was set by the property or was in ViewState, // we want to overwrite it. if (_textSetByAddParsedSubObject) { Text += ((LiteralControl)obj).Text; } else { Text = ((LiteralControl)obj).Text; } _textSetByAddParsedSubObject = true; } else { string currentText = Text; if (currentText.Length != 0) { Text = String.Empty; base.AddParsedSubObject(new LiteralControl(currentText)); } base.AddParsedSubObject(obj); } } } ////// /// protected override Style CreateControlStyle() { return new TableItemStyle(ViewState); } ///A protected /// method. Creates a table item control /// style. ////// /// protected internal override void RenderContents(HtmlTextWriter writer) { // We can't use HasControls() here, because we may have a compiled render method (ASURT 94127) if (HasRenderingData()) { base.RenderContents(writer); } else { writer.Write(Text); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.A protected method. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IImplicitResourceProvider.cs
- FrugalMap.cs
- TagMapCollection.cs
- AttachedPropertyMethodSelector.cs
- ObjectQueryProvider.cs
- DataChangedEventManager.cs
- AddInPipelineAttributes.cs
- DataGridDetailsPresenter.cs
- ContractsBCL.cs
- MethodToken.cs
- MSHTMLHostUtil.cs
- GeometryDrawing.cs
- InvokePattern.cs
- DataTableTypeConverter.cs
- DispatcherExceptionFilterEventArgs.cs
- SecureEnvironment.cs
- DocumentsTrace.cs
- List.cs
- ExtensionQuery.cs
- AppDomainAttributes.cs
- WebResponse.cs
- MarkupCompilePass2.cs
- FilterException.cs
- NameValuePermission.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- WebConfigurationFileMap.cs
- ResolveNameEventArgs.cs
- CodeTypeMemberCollection.cs
- ApplicationServicesHostFactory.cs
- WindowsListViewScroll.cs
- StorageEntityContainerMapping.cs
- SettingsBindableAttribute.cs
- JavaScriptSerializer.cs
- Container.cs
- XmlCharacterData.cs
- ScalarRestriction.cs
- SoapAttributeOverrides.cs
- DnsPermission.cs
- HtmlInputReset.cs
- EditorServiceContext.cs
- ColorMatrix.cs
- WinCategoryAttribute.cs
- ObjectDataSourceWizardForm.cs
- Content.cs
- SkewTransform.cs
- TimeSpanSecondsConverter.cs
- COM2AboutBoxPropertyDescriptor.cs
- ThicknessKeyFrameCollection.cs
- PermissionListSet.cs
- Sequence.cs
- TemplatedEditableDesignerRegion.cs
- WebPartZoneBase.cs
- HttpListenerException.cs
- StringReader.cs
- DetailsViewUpdateEventArgs.cs
- ResourceDictionary.cs
- SelectionRangeConverter.cs
- FixedSOMPageElement.cs
- DataTableMappingCollection.cs
- CodeTypeMemberCollection.cs
- LinkAreaEditor.cs
- BufferedWebEventProvider.cs
- XPathDocumentBuilder.cs
- IntegrationExceptionEventArgs.cs
- XPathDescendantIterator.cs
- SiteMapDataSourceView.cs
- OleDbInfoMessageEvent.cs
- StructuredTypeInfo.cs
- XmlElementAttributes.cs
- DataGridViewBindingCompleteEventArgs.cs
- X509CertificateValidationMode.cs
- NTAccount.cs
- AddInToken.cs
- glyphs.cs
- TextEditorDragDrop.cs
- ValidatedControlConverter.cs
- FragmentNavigationEventArgs.cs
- HyperLinkField.cs
- AxHostDesigner.cs
- mansign.cs
- MarshalByValueComponent.cs
- CodeObject.cs
- XLinq.cs
- InternalException.cs
- BuildManager.cs
- IndexObject.cs
- UnsafeNativeMethods.cs
- TextBox.cs
- CompilerGlobalScopeAttribute.cs
- MessagePropertyFilter.cs
- MarkupExtensionParser.cs
- WebPartCancelEventArgs.cs
- PersonalizationEntry.cs
- EntityWithKeyStrategy.cs
- InkCanvasAutomationPeer.cs
- CompilerErrorCollection.cs
- WebPartVerbCollection.cs
- BaseValidatorDesigner.cs
- ChildrenQuery.cs
- PartialList.cs