Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / UI / WebControls / Label.cs / 2 / Label.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing.Design;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
///
/// Interacts with the parser to build a control.
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class LabelControlBuilder : ControlBuilder {
///
///
/// Specifies whether white space literals are allowed.
///
public override bool AllowWhitespaceLiterals() {
return false;
}
}
///
/// Constructs a label for displaying text programmatcially on a
/// page.
///
[
ControlBuilderAttribute(typeof(LabelControlBuilder)),
ControlValueProperty("Text"),
DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + AssemblyRef.SystemDesign),
DefaultProperty("Text"),
ParseChildren(false),
Designer("System.Web.UI.Design.WebControls.LabelDesigner, " + AssemblyRef.SystemDesign),
ToolboxData("<{0}:Label runat=\"server\" Text=\"Label\">{0}:Label>")
]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class Label : WebControl, ITextControl {
///
/// Initializes a new instance of the class and renders
/// it as a SPAN tag.
///
public Label() {
}
///
///
internal Label(HtmlTextWriterTag tag) : base(tag) {
}
///
/// [To be supplied.]
///
[
DefaultValue(""),
IDReferenceProperty(),
TypeConverter(typeof(AssociatedControlConverter)),
WebCategory("Accessibility"),
WebSysDescription(SR.Label_AssociatedControlID),
Themeable(false)
]
public virtual string AssociatedControlID {
get {
string s = (string)ViewState["AssociatedControlID"];
return (s == null) ? String.Empty : s;
}
set {
ViewState["AssociatedControlID"] = value;
}
}
internal bool AssociatedControlInControlTree {
get {
object o = ViewState["AssociatedControlNotInControlTree"];
return (o == null ? true : (bool)o);
}
set {
ViewState["AssociatedControlNotInControlTree"] = value;
}
}
internal override bool RequiresLegacyRendering {
get {
return true;
}
}
protected override HtmlTextWriterTag TagKey {
get {
if (AssociatedControlID.Length != 0) {
return HtmlTextWriterTag.Label;
}
return base.TagKey;
}
}
///
/// Gets or sets the text content of the
/// control.
///
[
Localizable(true),
Bindable(true),
WebCategory("Appearance"),
DefaultValue(""),
WebSysDescription(SR.Label_Text),
PersistenceMode(PersistenceMode.InnerDefaultProperty)
]
public virtual string Text {
get {
object o = ViewState["Text"];
return((o == null) ? String.Empty : (string)o);
}
set {
if (HasControls()) {
Controls.Clear();
}
ViewState["Text"] = value;
}
}
protected override void AddAttributesToRender(HtmlTextWriter writer) {
string associatedControlID = AssociatedControlID;
if (associatedControlID.Length != 0) {
if (AssociatedControlInControlTree) {
Control wc = FindControl(associatedControlID);
if (wc == null) {
// Don't throw in the designer.
if (!DesignMode)
throw new HttpException(SR.GetString(SR.LabelForNotFound, associatedControlID, ID));
}
else {
writer.AddAttribute(HtmlTextWriterAttribute.For, wc.ClientID);
}
}
else {
writer.AddAttribute(HtmlTextWriterAttribute.For, associatedControlID);
}
}
base.AddAttributesToRender(writer);
}
///
///
///
protected override void AddParsedSubObject(object obj) {
if (HasControls()) {
base.AddParsedSubObject(obj);
}
else {
if (obj is LiteralControl) {
Text = ((LiteralControl)obj).Text;
}
else {
string currentText = Text;
if (currentText.Length != 0) {
Text = String.Empty;
base.AddParsedSubObject(new LiteralControl(currentText));
}
base.AddParsedSubObject(obj);
}
}
}
///
///
/// Load previously saved state.
/// Overridden to synchronize Text property with LiteralContent.
///
protected override void LoadViewState(object savedState) {
if (savedState != null) {
base.LoadViewState(savedState);
string s = (string)ViewState["Text"];
if (s != null)
Text = s;
}
}
///
///
/// Renders the contents of the into the specified writer.
///
protected internal override void RenderContents(HtmlTextWriter writer) {
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.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing.Design;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
///
/// Interacts with the parser to build a control.
///
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class LabelControlBuilder : ControlBuilder {
///
///
/// Specifies whether white space literals are allowed.
///
public override bool AllowWhitespaceLiterals() {
return false;
}
}
///
/// Constructs a label for displaying text programmatcially on a
/// page.
///
[
ControlBuilderAttribute(typeof(LabelControlBuilder)),
ControlValueProperty("Text"),
DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + AssemblyRef.SystemDesign),
DefaultProperty("Text"),
ParseChildren(false),
Designer("System.Web.UI.Design.WebControls.LabelDesigner, " + AssemblyRef.SystemDesign),
ToolboxData("<{0}:Label runat=\"server\" Text=\"Label\">{0}:Label>")
]
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class Label : WebControl, ITextControl {
///
/// Initializes a new instance of the class and renders
/// it as a SPAN tag.
///
public Label() {
}
///
///
internal Label(HtmlTextWriterTag tag) : base(tag) {
}
///
/// [To be supplied.]
///
[
DefaultValue(""),
IDReferenceProperty(),
TypeConverter(typeof(AssociatedControlConverter)),
WebCategory("Accessibility"),
WebSysDescription(SR.Label_AssociatedControlID),
Themeable(false)
]
public virtual string AssociatedControlID {
get {
string s = (string)ViewState["AssociatedControlID"];
return (s == null) ? String.Empty : s;
}
set {
ViewState["AssociatedControlID"] = value;
}
}
internal bool AssociatedControlInControlTree {
get {
object o = ViewState["AssociatedControlNotInControlTree"];
return (o == null ? true : (bool)o);
}
set {
ViewState["AssociatedControlNotInControlTree"] = value;
}
}
internal override bool RequiresLegacyRendering {
get {
return true;
}
}
protected override HtmlTextWriterTag TagKey {
get {
if (AssociatedControlID.Length != 0) {
return HtmlTextWriterTag.Label;
}
return base.TagKey;
}
}
///
/// Gets or sets the text content of the
/// control.
///
[
Localizable(true),
Bindable(true),
WebCategory("Appearance"),
DefaultValue(""),
WebSysDescription(SR.Label_Text),
PersistenceMode(PersistenceMode.InnerDefaultProperty)
]
public virtual string Text {
get {
object o = ViewState["Text"];
return((o == null) ? String.Empty : (string)o);
}
set {
if (HasControls()) {
Controls.Clear();
}
ViewState["Text"] = value;
}
}
protected override void AddAttributesToRender(HtmlTextWriter writer) {
string associatedControlID = AssociatedControlID;
if (associatedControlID.Length != 0) {
if (AssociatedControlInControlTree) {
Control wc = FindControl(associatedControlID);
if (wc == null) {
// Don't throw in the designer.
if (!DesignMode)
throw new HttpException(SR.GetString(SR.LabelForNotFound, associatedControlID, ID));
}
else {
writer.AddAttribute(HtmlTextWriterAttribute.For, wc.ClientID);
}
}
else {
writer.AddAttribute(HtmlTextWriterAttribute.For, associatedControlID);
}
}
base.AddAttributesToRender(writer);
}
///
///
///
protected override void AddParsedSubObject(object obj) {
if (HasControls()) {
base.AddParsedSubObject(obj);
}
else {
if (obj is LiteralControl) {
Text = ((LiteralControl)obj).Text;
}
else {
string currentText = Text;
if (currentText.Length != 0) {
Text = String.Empty;
base.AddParsedSubObject(new LiteralControl(currentText));
}
base.AddParsedSubObject(obj);
}
}
}
///
///
/// Load previously saved state.
/// Overridden to synchronize Text property with LiteralContent.
///
protected override void LoadViewState(object savedState) {
if (savedState != null) {
base.LoadViewState(savedState);
string s = (string)ViewState["Text"];
if (s != null)
Text = s;
}
}
///
///
/// Renders the contents of the into the specified writer.
///
protected internal override void RenderContents(HtmlTextWriter writer) {
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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TextLine.cs
- ElementHost.cs
- SemanticResultKey.cs
- RadioButtonList.cs
- TreeNode.cs
- EventsTab.cs
- CustomMenuItemCollection.cs
- TraceData.cs
- CustomAttribute.cs
- HorizontalAlignConverter.cs
- ContainerParaClient.cs
- KnowledgeBase.cs
- SemaphoreFullException.cs
- TableColumnCollectionInternal.cs
- Message.cs
- QueryReaderSettings.cs
- Unit.cs
- BCryptHashAlgorithm.cs
- recordstatescratchpad.cs
- QuaternionAnimation.cs
- SQLBinaryStorage.cs
- HiddenFieldPageStatePersister.cs
- KerberosTicketHashIdentifierClause.cs
- AuthenticationService.cs
- QueryCacheEntry.cs
- Filter.cs
- DesignerCommandAdapter.cs
- WasEndpointConfigContainer.cs
- CompilerTypeWithParams.cs
- XPathScanner.cs
- TypeLibConverter.cs
- BrowserCapabilitiesFactory.cs
- XmlSchemaAttributeGroupRef.cs
- TimeSpanStorage.cs
- TiffBitmapDecoder.cs
- BitmapCacheBrush.cs
- XPathSelfQuery.cs
- XMLSchema.cs
- ErrorHandlingAcceptor.cs
- CategoriesDocument.cs
- Util.cs
- WebPartDisplayMode.cs
- UnsafeNativeMethods.cs
- WebPartDescription.cs
- MouseActionConverter.cs
- IISUnsafeMethods.cs
- DataServiceHostFactory.cs
- UnitySerializationHolder.cs
- ShortcutKeysEditor.cs
- WindowsRichEdit.cs
- FileRecordSequenceCompletedAsyncResult.cs
- NativeMethods.cs
- SafeRegistryHandle.cs
- BitmapVisualManager.cs
- ModifierKeysConverter.cs
- WindowAutomationPeer.cs
- LinqDataSourceEditData.cs
- DataGridViewTopRowAccessibleObject.cs
- IconEditor.cs
- PersonalizationAdministration.cs
- DataTrigger.cs
- FixedSOMTextRun.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- EntityDataSourceContextCreatedEventArgs.cs
- EnumUnknown.cs
- NetworkInformationException.cs
- SqlFacetAttribute.cs
- Int64AnimationUsingKeyFrames.cs
- SqlBooleanMismatchVisitor.cs
- DataGridViewLinkColumn.cs
- DbModificationClause.cs
- SizeF.cs
- InvalidOleVariantTypeException.cs
- VisemeEventArgs.cs
- ScaleTransform.cs
- WebEventCodes.cs
- IPEndPoint.cs
- BindingContext.cs
- IncrementalReadDecoders.cs
- RuntimeVariableList.cs
- OpenTypeLayoutCache.cs
- ThrowOnMultipleAssignment.cs
- WebPartTransformerAttribute.cs
- WindowsAltTab.cs
- RTLAwareMessageBox.cs
- DataBinder.cs
- ScriptReference.cs
- MenuItemCollection.cs
- PropertyGrid.cs
- XPathDocumentIterator.cs
- DefaultTextStoreTextComposition.cs
- PreparingEnlistment.cs
- BlockCollection.cs
- PointUtil.cs
- EntityTypeEmitter.cs
- DBConnection.cs
- DataGridViewLinkColumn.cs
- StylusLogic.cs
- XsdCachingReader.cs
- propertytag.cs