Code:
/ FX-1434 / FX-1434 / 1.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
- IndicShape.cs
- FloaterParagraph.cs
- ComponentResourceKeyConverter.cs
- SynchronizationValidator.cs
- StreamWithDictionary.cs
- PagesSection.cs
- HtmlInputCheckBox.cs
- TreeViewHitTestInfo.cs
- ConstNode.cs
- Popup.cs
- DefaultDialogButtons.cs
- SymbolPair.cs
- WCFModelStrings.Designer.cs
- CompositeFontFamily.cs
- _LocalDataStoreMgr.cs
- PerformanceCounterPermissionEntry.cs
- BamlRecordReader.cs
- XPathException.cs
- loginstatus.cs
- GeometryHitTestResult.cs
- filewebrequest.cs
- ServiceAuthorizationBehavior.cs
- DefaultBindingPropertyAttribute.cs
- XpsS0ValidatingLoader.cs
- JavaScriptObjectDeserializer.cs
- TextFormatter.cs
- ClipboardProcessor.cs
- StringUtil.cs
- FileLevelControlBuilderAttribute.cs
- SplashScreenNativeMethods.cs
- WebBaseEventKeyComparer.cs
- Style.cs
- ExceptionUtil.cs
- Control.cs
- TypeExtensions.cs
- Enum.cs
- DEREncoding.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- HMACSHA384.cs
- TypeToken.cs
- WebPartUtil.cs
- CodeNamespaceImportCollection.cs
- OutputCache.cs
- FontCollection.cs
- FileVersionInfo.cs
- DataListComponentEditor.cs
- CultureTable.cs
- Bold.cs
- ManagementBaseObject.cs
- WindowsListView.cs
- AssemblyUtil.cs
- DesignerAttribute.cs
- DataGridTableCollection.cs
- ImmutableCollection.cs
- DayRenderEvent.cs
- SqlCacheDependencySection.cs
- PathGeometry.cs
- AppDomainAttributes.cs
- PropertyToken.cs
- XamlWriter.cs
- VSDExceptions.cs
- TypeBuilder.cs
- LogicalTreeHelper.cs
- AssemblyBuilder.cs
- Opcode.cs
- ProfilePropertySettingsCollection.cs
- SchemaNamespaceManager.cs
- ByeOperation11AsyncResult.cs
- DynamicActivityTypeDescriptor.cs
- JumpList.cs
- PointConverter.cs
- ImageMap.cs
- CardSpaceShim.cs
- CurrentChangingEventManager.cs
- LoopExpression.cs
- PeerOutputChannel.cs
- UpdateCommand.cs
- unsafenativemethodsother.cs
- SignedXml.cs
- TextBoxRenderer.cs
- HierarchicalDataBoundControlAdapter.cs
- CqlParser.cs
- TableRowCollection.cs
- ResourceType.cs
- StyleBamlRecordReader.cs
- StylusCaptureWithinProperty.cs
- FilterEventArgs.cs
- XmlSchemaAttribute.cs
- UIElement3DAutomationPeer.cs
- HttpPostedFile.cs
- MessageCredentialType.cs
- GiveFeedbackEventArgs.cs
- MaterialGroup.cs
- EventLogQuery.cs
- BitmapCodecInfoInternal.cs
- TypeNameConverter.cs
- AnyAllSearchOperator.cs
- TemplatedWizardStep.cs
- ResponseBodyWriter.cs
- AccessorTable.cs