Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / TextControlDesigner.cs / 1 / TextControlDesigner.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.Design {
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Globalization;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Web.UI;
///
///
///
/// This designer can be used for controls which provide a Text property that
/// is persisted as inner text. An example of such as control is the
/// System.Web.UI.WebControls.Label class. This designer ensures that the
/// Text property is set to some default value to ensure design-time visibility
/// while preserving the children collection intact. It also ensures correct
/// persistence of inner contents in both scenarios: inner text and child controls.
///
///
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)]
public class TextControlDesigner : ControlDesigner {
///
public override string GetDesignTimeHtml() {
Control control = ViewControl;
PropertyInfo textPropInfo = control.GetType().GetProperty("Text");
string originalText = (string)textPropInfo.GetValue(control, null);
bool blank = (originalText == null) || (originalText.Length == 0);
bool hasControls = control.HasControls();
Control[] children = null;
if (blank) {
if (hasControls) {
children = new Control[control.Controls.Count];
control.Controls.CopyTo(children, 0);
}
textPropInfo.SetValue(control, "[" + control.ID + "]", null);
}
string html;
try {
html = base.GetDesignTimeHtml();
}
finally {
if (blank) {
textPropInfo.SetValue(control, originalText, null);
if (hasControls) {
foreach (Control c in children) {
control.Controls.Add(c);
}
}
}
}
return html;
}
}
}
// 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
- Vector3DAnimation.cs
- CreateUserErrorEventArgs.cs
- TCEAdapterGenerator.cs
- TransformBlockRequest.cs
- EventListenerClientSide.cs
- QilScopedVisitor.cs
- cookie.cs
- UnSafeCharBuffer.cs
- DecoderExceptionFallback.cs
- BinaryMethodMessage.cs
- TextEndOfSegment.cs
- MessageQueueAccessControlEntry.cs
- RemoveStoryboard.cs
- ClientConfigPaths.cs
- SchemaNamespaceManager.cs
- SQLBinary.cs
- ByteKeyFrameCollection.cs
- CompositeControl.cs
- InstalledFontCollection.cs
- BitmapEffectGroup.cs
- QuotedStringWriteStateInfo.cs
- TypeLibConverter.cs
- UserUseLicenseDictionaryLoader.cs
- ButtonFlatAdapter.cs
- RawStylusInputCustomData.cs
- CatalogZoneAutoFormat.cs
- DocumentSchemaValidator.cs
- OperationAbortedException.cs
- Vector3DCollectionConverter.cs
- Compiler.cs
- CodeAttributeArgumentCollection.cs
- safelink.cs
- StylusPlugin.cs
- DataFieldConverter.cs
- DependencyObjectProvider.cs
- TabletCollection.cs
- SmiMetaData.cs
- Parser.cs
- MessageFilter.cs
- ServiceModelActivity.cs
- SoapHeaderException.cs
- OdbcConnectionStringbuilder.cs
- XhtmlBasicValidatorAdapter.cs
- FixedDSBuilder.cs
- ListViewUpdateEventArgs.cs
- SafeUserTokenHandle.cs
- ProxyWebPartConnectionCollection.cs
- SafeThreadHandle.cs
- DataGridViewCellValueEventArgs.cs
- AssociationSetMetadata.cs
- HtmlTextBoxAdapter.cs
- HttpCapabilitiesEvaluator.cs
- HtmlInputCheckBox.cs
- DelayDesigner.cs
- ObjectHandle.cs
- SafeViewOfFileHandle.cs
- CustomAttributeBuilder.cs
- HandlerBase.cs
- ChtmlSelectionListAdapter.cs
- DataGridViewAccessibleObject.cs
- PreviewKeyDownEventArgs.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- Utilities.cs
- TextSerializer.cs
- PersistenceTypeAttribute.cs
- DateTimeFormatInfoScanner.cs
- PageSetupDialog.cs
- ApplicationManager.cs
- DiscardableAttribute.cs
- XmlSchemaObjectCollection.cs
- XmlWrappingReader.cs
- StateMachine.cs
- HtmlEncodedRawTextWriter.cs
- Conditional.cs
- BorderSidesEditor.cs
- SwitchLevelAttribute.cs
- RangeValueProviderWrapper.cs
- FunctionImportElement.cs
- CroppedBitmap.cs
- FormsAuthentication.cs
- ProgressPage.cs
- ContainerAction.cs
- _DomainName.cs
- DataGridTableStyleMappingNameEditor.cs
- ClientTargetSection.cs
- HttpWebRequestElement.cs
- SessionStateUtil.cs
- SystemException.cs
- DocumentsTrace.cs
- SqlFactory.cs
- TextSelectionProcessor.cs
- ZipArchive.cs
- ButtonField.cs
- ApplicationSettingsBase.cs
- TypeHelper.cs
- _DomainName.cs
- TextTreeUndo.cs
- DbDataAdapter.cs
- unsafenativemethodstextservices.cs
- ListView.cs