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
- FontWeightConverter.cs
- Menu.cs
- SyndicationItem.cs
- FormatterServices.cs
- Int32CAMarshaler.cs
- CustomCredentialPolicy.cs
- ThreadInterruptedException.cs
- BoundColumn.cs
- JsonEncodingStreamWrapper.cs
- ObjectConverter.cs
- ToolStripItemCollection.cs
- SqlDataReaderSmi.cs
- RelationalExpressions.cs
- RedBlackList.cs
- columnmapkeybuilder.cs
- URLMembershipCondition.cs
- PropertiesTab.cs
- System.Data_BID.cs
- ToolStripItemGlyph.cs
- PrivateFontCollection.cs
- ProfileService.cs
- EndpointIdentityConverter.cs
- TextTreeUndoUnit.cs
- DataGridViewCellStyleChangedEventArgs.cs
- DataGridViewSelectedRowCollection.cs
- BitmapEffect.cs
- mediaclock.cs
- GradientPanel.cs
- ApplicationSecurityInfo.cs
- CertificateManager.cs
- MediaEntryAttribute.cs
- CompilerInfo.cs
- FloaterParagraph.cs
- DbProviderSpecificTypePropertyAttribute.cs
- Int64Animation.cs
- webclient.cs
- ContentFilePart.cs
- BordersPage.cs
- DirectoryObjectSecurity.cs
- DataGridViewCellCollection.cs
- ProtocolsConfigurationHandler.cs
- Win32PrintDialog.cs
- Random.cs
- HexParser.cs
- DefaultTextStore.cs
- RelationshipManager.cs
- TableAdapterManagerMethodGenerator.cs
- DoneReceivingAsyncResult.cs
- RenderDataDrawingContext.cs
- DocumentApplicationJournalEntry.cs
- ToolStripItemTextRenderEventArgs.cs
- DataGridViewColumnEventArgs.cs
- DoubleLinkListEnumerator.cs
- TextBoxView.cs
- Constraint.cs
- XsltLibrary.cs
- BinaryExpression.cs
- C14NUtil.cs
- XmlDesignerDataSourceView.cs
- PermissionSet.cs
- FontDriver.cs
- Int32RectConverter.cs
- SerializationAttributes.cs
- PageCatalogPart.cs
- DbParameterHelper.cs
- ToolStripLocationCancelEventArgs.cs
- XmlObjectSerializer.cs
- WorkflowMessageEventHandler.cs
- SupportingTokenAuthenticatorSpecification.cs
- TranslateTransform3D.cs
- GcSettings.cs
- ToolStripContainer.cs
- ActivationArguments.cs
- SoapEnvelopeProcessingElement.cs
- AdornerDecorator.cs
- ClockGroup.cs
- PagedDataSource.cs
- Listbox.cs
- StylusPointCollection.cs
- ColumnCollection.cs
- XMLSyntaxException.cs
- GridItemProviderWrapper.cs
- SecurityTokenProviderContainer.cs
- NetPipeSectionData.cs
- FtpWebRequest.cs
- GenericUriParser.cs
- CaseInsensitiveHashCodeProvider.cs
- DataControlImageButton.cs
- PrtTicket_Public.cs
- ViewStateModeByIdAttribute.cs
- ConfigurationPropertyCollection.cs
- CodeDirectoryCompiler.cs
- WebPartHeaderCloseVerb.cs
- Point3D.cs
- DbMetaDataFactory.cs
- PriorityQueue.cs
- XmlNodeChangedEventArgs.cs
- ContextProperty.cs
- Timer.cs
- ContainerVisual.cs