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
- CompiledRegexRunner.cs
- TextBounds.cs
- ApplyImportsAction.cs
- DbDeleteCommandTree.cs
- StylusDevice.cs
- SchemaSetCompiler.cs
- FilterableAttribute.cs
- ValueUtilsSmi.cs
- UnsafeNativeMethods.cs
- MessageFormatterConverter.cs
- SqlAliaser.cs
- StrongNamePublicKeyBlob.cs
- TemplateParser.cs
- Column.cs
- HtmlForm.cs
- TypeGeneratedEventArgs.cs
- MissingManifestResourceException.cs
- InstanceDescriptor.cs
- SmiEventStream.cs
- SizeIndependentAnimationStorage.cs
- EntitySqlQueryBuilder.cs
- IndexOutOfRangeException.cs
- PropertyEntry.cs
- XmlWriterDelegator.cs
- EventDrivenDesigner.cs
- MediaEntryAttribute.cs
- CompareValidator.cs
- HGlobalSafeHandle.cs
- DoubleLink.cs
- SizeAnimationUsingKeyFrames.cs
- Label.cs
- ObjectListCommandEventArgs.cs
- WsatServiceAddress.cs
- DependencyObjectProvider.cs
- BaseServiceProvider.cs
- TextBlock.cs
- WeakReference.cs
- ProviderConnectionPoint.cs
- SafeNativeMethodsCLR.cs
- EllipseGeometry.cs
- BaseDataListDesigner.cs
- BitmapFrame.cs
- XmlTextEncoder.cs
- TdsParserStateObject.cs
- XamlPathDataSerializer.cs
- TextReader.cs
- UnsafeMethods.cs
- ProfilePropertySettingsCollection.cs
- TextServicesPropertyRanges.cs
- DataGridComponentEditor.cs
- SingleKeyFrameCollection.cs
- FileReservationCollection.cs
- StateElement.cs
- DataServiceProcessingPipelineEventArgs.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- XmlBoundElement.cs
- querybuilder.cs
- RadioButtonRenderer.cs
- MULTI_QI.cs
- ButtonPopupAdapter.cs
- ContextConfiguration.cs
- ProcessHostMapPath.cs
- GroupQuery.cs
- CodeMemberEvent.cs
- XmlSchemaSubstitutionGroup.cs
- BitmapFrame.cs
- Endpoint.cs
- SiteMap.cs
- MatrixStack.cs
- FontFamilyIdentifier.cs
- _Win32.cs
- ManualResetEventSlim.cs
- dataSvcMapFileLoader.cs
- WebFormDesignerActionService.cs
- Int16.cs
- ControlValuePropertyAttribute.cs
- ReadOnlyKeyedCollection.cs
- WebControlToolBoxItem.cs
- RemoteWebConfigurationHostStream.cs
- FtpWebRequest.cs
- OleDbInfoMessageEvent.cs
- OrthographicCamera.cs
- ApplicationBuildProvider.cs
- ThrowOnMultipleAssignment.cs
- FieldNameLookup.cs
- _SslState.cs
- AlgoModule.cs
- TemplateField.cs
- SchemaNamespaceManager.cs
- MsmqDiagnostics.cs
- ConditionCollection.cs
- BorderGapMaskConverter.cs
- EndpointInfoCollection.cs
- ConfigurationManagerHelperFactory.cs
- ModelService.cs
- sqlser.cs
- Size.cs
- SmiEventStream.cs
- DataPagerFieldCollection.cs
- StandardRuntimeEnumValidator.cs