Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / HtmlControls / HtmlContainerControl.cs / 1305376 / HtmlContainerControl.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.HtmlControls { using System.Runtime.Serialization.Formatters; using System; using System.Collections; using System.ComponentModel; using System.IO; using System.Web.UI; using System.Security.Permissions; /* * A control representing an intrinsic Html tag. */ ////// abstract public class HtmlContainerControl : HtmlControl { /* * Creates a new WebControl */ ///The ////// class defines the methods, /// properties and events /// available to all Html Server controls that must have a /// closing tag. /// protected HtmlContainerControl() : this("span") { } /* * Creates a new HtmlContainerControl */ ///Initializes a new instance of a ///class using /// default values. /// public HtmlContainerControl(string tag) : base(tag) { } /* * The inner html content between the begin and end tag. * A set will replace any existing child controls with a single literal. * A get will return the text of a single literal child OR * will throw an exception if there are no children, more than one * child, or the single child is not a literal. */ ///Initializes a new instance of a ///class using the /// specified string. /// [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), HtmlControlPersistable(false), ] public virtual string InnerHtml { get { if (IsLiteralContent()) return((LiteralControl) Controls[0]).Text; else if (HasControls() && (Controls.Count == 1) && Controls[0] is DataBoundLiteralControl) return ((DataBoundLiteralControl) Controls[0]).Text; else { if (Controls.Count == 0) return String.Empty; throw new HttpException(SR.GetString(SR.Inner_Content_not_literal, ID)); } } set { Controls.Clear(); Controls.Add(new LiteralControl(value)); ViewState["innerhtml"] = value; } } /* * The inner text content between the begin and end tag. * A set will replace any existing child controls with a single literal. * A get will return the text of a single literal child OR * will throw an exception if there are no children, more than one child, or * the single child is not a literal. */ ////// Gets or sets the /// content found between the opening and closing tags of the specified HTML server control. /// ////// [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), HtmlControlPersistable(false), ] public virtual string InnerText { get { return HttpUtility.HtmlDecode(InnerHtml); } set { InnerHtml = HttpUtility.HtmlEncode(value); } } ////// Gets or sets all text between the opening and closing tags /// of the specified HTML server control. /// ////// protected override ControlCollection CreateControlCollection() { return new ControlCollection(this); } ///[To be supplied.] ////// /// protected override void LoadViewState(object savedState) { if (savedState != null) { base.LoadViewState(savedState); string s = (string)ViewState["innerhtml"]; // Dev10 703061 If InnerHtml is set, we want to clear out any child controls, but not dirty viewstate if (s != null) { Controls.Clear(); Controls.Add(new LiteralControl(s)); } } } /* * Render the control into the given writer. */ ////// /// protected internal override void Render(HtmlTextWriter writer) { RenderBeginTag(writer); RenderChildren(writer); RenderEndTag(writer); } /* * Override to prevent InnerHtml from being rendered as an attribute. */ ////// /// protected override void RenderAttributes(HtmlTextWriter writer) { ViewState.Remove("innerhtml"); base.RenderAttributes(writer); } /* * Render the end tag, </TAGNAME>. */ ////// /// protected virtual void RenderEndTag(HtmlTextWriter writer) { writer.WriteEndTag(TagName); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.HtmlControls { using System.Runtime.Serialization.Formatters; using System; using System.Collections; using System.ComponentModel; using System.IO; using System.Web.UI; using System.Security.Permissions; /* * A control representing an intrinsic Html tag. */ ////// abstract public class HtmlContainerControl : HtmlControl { /* * Creates a new WebControl */ ///The ////// class defines the methods, /// properties and events /// available to all Html Server controls that must have a /// closing tag. /// protected HtmlContainerControl() : this("span") { } /* * Creates a new HtmlContainerControl */ ///Initializes a new instance of a ///class using /// default values. /// public HtmlContainerControl(string tag) : base(tag) { } /* * The inner html content between the begin and end tag. * A set will replace any existing child controls with a single literal. * A get will return the text of a single literal child OR * will throw an exception if there are no children, more than one * child, or the single child is not a literal. */ ///Initializes a new instance of a ///class using the /// specified string. /// [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), HtmlControlPersistable(false), ] public virtual string InnerHtml { get { if (IsLiteralContent()) return((LiteralControl) Controls[0]).Text; else if (HasControls() && (Controls.Count == 1) && Controls[0] is DataBoundLiteralControl) return ((DataBoundLiteralControl) Controls[0]).Text; else { if (Controls.Count == 0) return String.Empty; throw new HttpException(SR.GetString(SR.Inner_Content_not_literal, ID)); } } set { Controls.Clear(); Controls.Add(new LiteralControl(value)); ViewState["innerhtml"] = value; } } /* * The inner text content between the begin and end tag. * A set will replace any existing child controls with a single literal. * A get will return the text of a single literal child OR * will throw an exception if there are no children, more than one child, or * the single child is not a literal. */ ////// Gets or sets the /// content found between the opening and closing tags of the specified HTML server control. /// ////// [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), HtmlControlPersistable(false), ] public virtual string InnerText { get { return HttpUtility.HtmlDecode(InnerHtml); } set { InnerHtml = HttpUtility.HtmlEncode(value); } } ////// Gets or sets all text between the opening and closing tags /// of the specified HTML server control. /// ////// protected override ControlCollection CreateControlCollection() { return new ControlCollection(this); } ///[To be supplied.] ////// /// protected override void LoadViewState(object savedState) { if (savedState != null) { base.LoadViewState(savedState); string s = (string)ViewState["innerhtml"]; // Dev10 703061 If InnerHtml is set, we want to clear out any child controls, but not dirty viewstate if (s != null) { Controls.Clear(); Controls.Add(new LiteralControl(s)); } } } /* * Render the control into the given writer. */ ////// /// protected internal override void Render(HtmlTextWriter writer) { RenderBeginTag(writer); RenderChildren(writer); RenderEndTag(writer); } /* * Override to prevent InnerHtml from being rendered as an attribute. */ ////// /// protected override void RenderAttributes(HtmlTextWriter writer) { ViewState.Remove("innerhtml"); base.RenderAttributes(writer); } /* * Render the end tag, </TAGNAME>. */ ////// /// protected virtual void RenderEndTag(HtmlTextWriter writer) { writer.WriteEndTag(TagName); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ComboBoxItem.cs
- FileEnumerator.cs
- SoapAttributes.cs
- AnnotationResourceCollection.cs
- ScriptDescriptor.cs
- XsltContext.cs
- XmlSchemaSimpleContentExtension.cs
- ExcCanonicalXml.cs
- XmlSignificantWhitespace.cs
- HttpModulesSection.cs
- InvalidPipelineStoreException.cs
- DataChangedEventManager.cs
- TraceUtils.cs
- MouseButton.cs
- AutomationPeer.cs
- Type.cs
- ButtonFlatAdapter.cs
- EnumMember.cs
- iisPickupDirectory.cs
- DataServiceRequestOfT.cs
- TemplateComponentConnector.cs
- Trace.cs
- DataPagerField.cs
- COM2TypeInfoProcessor.cs
- BrowsableAttribute.cs
- ParameterBuilder.cs
- DoubleMinMaxAggregationOperator.cs
- NonParentingControl.cs
- DataBoundControlActionList.cs
- CursorConverter.cs
- ConstructorNeedsTagAttribute.cs
- CompareInfo.cs
- Timer.cs
- WebPartsPersonalizationAuthorization.cs
- ContentIterators.cs
- ListBoxItemAutomationPeer.cs
- ZoneLinkButton.cs
- SynchronizedDispatch.cs
- RoleGroupCollection.cs
- TextEditor.cs
- DelegatingConfigHost.cs
- Matrix3D.cs
- CallbackHandler.cs
- XsdDataContractExporter.cs
- LinkedList.cs
- SimpleWebHandlerParser.cs
- DataServiceHostFactory.cs
- InlineObject.cs
- SoundPlayerAction.cs
- DataSpaceManager.cs
- LogicalTreeHelper.cs
- SelectionRangeConverter.cs
- WebPartCloseVerb.cs
- Vector3DAnimation.cs
- IIS7UserPrincipal.cs
- UnsettableComboBox.cs
- MultipleViewPattern.cs
- Point3DConverter.cs
- FormattedText.cs
- FormViewInsertEventArgs.cs
- FullTextBreakpoint.cs
- ConversionHelper.cs
- WebSysDescriptionAttribute.cs
- PackUriHelper.cs
- StreamResourceInfo.cs
- HttpRuntime.cs
- ToolStripRenderEventArgs.cs
- ProfileParameter.cs
- TransactionBridge.cs
- MethodMessage.cs
- TcpStreams.cs
- ToggleButtonAutomationPeer.cs
- SHA384Managed.cs
- ResourcesGenerator.cs
- TypeValidationEventArgs.cs
- SystemPens.cs
- TextSelectionProcessor.cs
- EntityModelBuildProvider.cs
- NativeStructs.cs
- WebUtil.cs
- DoubleLink.cs
- DataGridToolTip.cs
- DetailsViewPagerRow.cs
- QilScopedVisitor.cs
- BinHexEncoding.cs
- XsltSettings.cs
- Number.cs
- BamlBinaryReader.cs
- EntityDataSourceContextDisposingEventArgs.cs
- SignatureTargetIdManager.cs
- UrlMappingCollection.cs
- AvTraceDetails.cs
- SqlUDTStorage.cs
- Simplifier.cs
- TransactionBehavior.cs
- _UriSyntax.cs
- WebPartCatalogAddVerb.cs
- AspCompat.cs
- ValueUnavailableException.cs
- ConfigurationStrings.cs