Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / UI / HtmlControls / HtmlContainerControl.cs / 1 / 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.
*/
///
/// The
/// class defines the methods,
/// properties and events
/// available to all Html Server controls that must have a
/// closing tag.
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
abstract public class HtmlContainerControl : HtmlControl {
/*
* Creates a new WebControl
*/
///
/// Initializes a new instance of a class using
/// default values.
///
protected HtmlContainerControl() : this("span") {
}
/*
* Creates a new HtmlContainerControl
*/
///
/// Initializes a new instance of a class using the
/// specified string.
///
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.
*/
///
///
/// 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 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 all text 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);
}
}
///
/// [To be supplied.]
///
protected override ControlCollection CreateControlCollection() {
return new ControlCollection(this);
}
///
///
///
protected override void LoadViewState(object savedState) {
if (savedState != null) {
base.LoadViewState(savedState);
string s = (string)ViewState["innerhtml"];
if (s != null)
InnerHtml = 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.
*/
///
/// The
/// class defines the methods,
/// properties and events
/// available to all Html Server controls that must have a
/// closing tag.
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
abstract public class HtmlContainerControl : HtmlControl {
/*
* Creates a new WebControl
*/
///
/// Initializes a new instance of a class using
/// default values.
///
protected HtmlContainerControl() : this("span") {
}
/*
* Creates a new HtmlContainerControl
*/
///
/// Initializes a new instance of a class using the
/// specified string.
///
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.
*/
///
///
/// 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 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 all text 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);
}
}
///
/// [To be supplied.]
///
protected override ControlCollection CreateControlCollection() {
return new ControlCollection(this);
}
///
///
///
protected override void LoadViewState(object savedState) {
if (savedState != null) {
base.LoadViewState(savedState);
string s = (string)ViewState["innerhtml"];
if (s != null)
InnerHtml = 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
- CmsUtils.cs
- BitmapCacheBrush.cs
- PhysicalAddress.cs
- ClickablePoint.cs
- EmptyEnumerator.cs
- LifetimeServices.cs
- PathGradientBrush.cs
- LinkedResource.cs
- UrlMappingCollection.cs
- TextLine.cs
- ThreadExceptionEvent.cs
- LineServicesCallbacks.cs
- RowCache.cs
- validationstate.cs
- DashStyle.cs
- FontEditor.cs
- BaseCodePageEncoding.cs
- CodePageEncoding.cs
- _SSPIWrapper.cs
- CompiledIdentityConstraint.cs
- HashCodeCombiner.cs
- TemplateControlParser.cs
- BreadCrumbTextConverter.cs
- KeyValueInternalCollection.cs
- ColorConvertedBitmap.cs
- RepeaterItemCollection.cs
- InertiaExpansionBehavior.cs
- IDispatchConstantAttribute.cs
- GenericUriParser.cs
- FixedDocumentSequencePaginator.cs
- PolyBezierSegment.cs
- BooleanExpr.cs
- MemberHolder.cs
- TypeConverterValueSerializer.cs
- TabControlCancelEvent.cs
- OutputCacheProfile.cs
- ServiceNameElement.cs
- NavigationExpr.cs
- TransformPattern.cs
- MbpInfo.cs
- SchemaEntity.cs
- SystemDiagnosticsSection.cs
- Point3DValueSerializer.cs
- NameScopePropertyAttribute.cs
- XPathNavigatorReader.cs
- BamlRecordHelper.cs
- IItemProperties.cs
- DragCompletedEventArgs.cs
- DocumentViewerHelper.cs
- oledbmetadatacolumnnames.cs
- SelectionList.cs
- RouteData.cs
- sqlser.cs
- PackUriHelper.cs
- SmiContextFactory.cs
- ToolConsole.cs
- XmlAttributeCache.cs
- WebPartTransformerCollection.cs
- FixedSOMGroup.cs
- _TimerThread.cs
- RegexMatchCollection.cs
- IISMapPath.cs
- bindurihelper.cs
- CodeSnippetCompileUnit.cs
- WebEncodingValidatorAttribute.cs
- ObjectView.cs
- DataAdapter.cs
- MessagePartDescriptionCollection.cs
- SQLString.cs
- SynchronizedReadOnlyCollection.cs
- mactripleDES.cs
- XPathSelfQuery.cs
- BamlCollectionHolder.cs
- EntitySqlQueryCacheKey.cs
- ListViewInsertionMark.cs
- ToolStripKeyboardHandlingService.cs
- SmtpNegotiateAuthenticationModule.cs
- StrongNameMembershipCondition.cs
- PropertyExpression.cs
- WebPartDescription.cs
- CodeSubDirectoriesCollection.cs
- WindowCollection.cs
- BufferedGraphicsManager.cs
- ArgumentOutOfRangeException.cs
- Bits.cs
- SessionKeyExpiredException.cs
- XmlSchemaType.cs
- TypeDelegator.cs
- MSAANativeProvider.cs
- SapiGrammar.cs
- OpenFileDialog.cs
- XamlVector3DCollectionSerializer.cs
- SmiSettersStream.cs
- DataView.cs
- CaseInsensitiveOrdinalStringComparer.cs
- DataTableClearEvent.cs
- LocalizationParserHooks.cs
- GatewayIPAddressInformationCollection.cs
- DependencyObjectType.cs
- GeneralTransform.cs