Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / DynamicData / DynamicData / DynamicEntity.cs / 1305376 / DynamicEntity.cs
using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Globalization; using System.Web.DynamicData.Util; using System.Web.Resources; using System.Web.UI; using System.Web.UI.WebControls; namespace System.Web.DynamicData { [ToolboxBitmap(typeof(DynamicEntity), "DynamicEntity.bmp")] public class DynamicEntity : Control { private HttpContextBase _context; [ DefaultValue(DataBoundControlMode.ReadOnly), Category("Behavior"), ResourceDescription("DynamicEntity_Mode") ] public DataBoundControlMode Mode { get { var value = ViewState["Mode"]; return value != null ? (DataBoundControlMode)value : DataBoundControlMode.ReadOnly; } set { ViewState["Mode"] = value; } } [ DefaultValue(""), Category("Behavior"), ResourceDescription("DynamicControlFieldCommon_UIHint") ] public string UIHint { get { return (string)ViewState["UIHint"] ?? String.Empty; } set { ViewState["UIHint"] = value; } } [ Category("Behavior"), DefaultValue(""), Themeable(false), ResourceDescription("DynamicControlFieldCommon_ValidationGroup") ] public string ValidationGroup { get { return (string)ViewState["ValidationGroup"] ?? String.Empty; } set { ViewState["ValidationGroup"] = value; } } private new HttpContextBase Context { get { return _context ?? new HttpContextWrapper(HttpContext.Current); } } public DynamicEntity() { } // for unit testing internal DynamicEntity(HttpContextBase context) : this() { _context = context; } [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers", MessageId = "0#")] protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (DesignMode) { return; } MetaTable table = MetaTableHelper.FindMetaTable(this, Context); if (table == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.DynamicEntity_ControlNeedsToExistInAContextSupportingDynamicData, this.ID)); } EntityTemplateFactory entityTemplateFactory = table.Model.EntityTemplateFactory; EntityTemplateUserControl entityTemplateControl = entityTemplateFactory.CreateEntityTemplate(table, Mode, UIHint); if (entityTemplateControl == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.DynamicEntity_CantFindTemplate, table.Name, entityTemplateFactory.TemplateFolderVirtualPath)); } entityTemplateControl.Mode = Mode; entityTemplateControl.ValidationGroup = ValidationGroup; entityTemplateControl.Table = table; Controls.Add(entityTemplateControl); } protected override void Render(HtmlTextWriter writer) { if (DesignMode) { writer.Write("[" + GetType().Name + "]"); } else { base.Render(writer); } } } } // 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
- TableHeaderCell.cs
- BufferedReadStream.cs
- XmlDictionaryReader.cs
- Util.cs
- ControlValuePropertyAttribute.cs
- HttpCachePolicyElement.cs
- WSMessageEncoding.cs
- InvalidFilterCriteriaException.cs
- AccessViolationException.cs
- MultipartIdentifier.cs
- StorageEndPropertyMapping.cs
- InputBuffer.cs
- ReaderWriterLock.cs
- DataGridState.cs
- SingleAnimation.cs
- PropertyEmitter.cs
- TableLayoutRowStyleCollection.cs
- DesignerDataSourceView.cs
- FormatConvertedBitmap.cs
- NumberFunctions.cs
- DescendantQuery.cs
- UndoEngine.cs
- StyleSelector.cs
- JsonFormatGeneratorStatics.cs
- WebPartTransformer.cs
- DataChangedEventManager.cs
- GridLengthConverter.cs
- XmlDataContract.cs
- MetadataCache.cs
- AlternateView.cs
- ConnectionPoolManager.cs
- WebPartTracker.cs
- SHA512.cs
- FileDetails.cs
- HttpWebResponse.cs
- AttachmentService.cs
- ExtenderProvidedPropertyAttribute.cs
- CodePageEncoding.cs
- uribuilder.cs
- DataRelation.cs
- XmlTextEncoder.cs
- NullRuntimeConfig.cs
- MonthChangedEventArgs.cs
- DecoderFallback.cs
- BindableAttribute.cs
- SortableBindingList.cs
- _MultipleConnectAsync.cs
- Convert.cs
- FlagPanel.cs
- DataConnectionHelper.cs
- SettingsBindableAttribute.cs
- LocalizableAttribute.cs
- Mapping.cs
- PassportIdentity.cs
- XmlMtomWriter.cs
- activationcontext.cs
- ProtocolsSection.cs
- ValueHandle.cs
- LinearGradientBrush.cs
- ContextMarshalException.cs
- EntitySqlQueryBuilder.cs
- PagesSection.cs
- SelectionListComponentEditor.cs
- AspProxy.cs
- DesignerAdapterAttribute.cs
- TypeUtils.cs
- StringUtil.cs
- ConstraintStruct.cs
- CharUnicodeInfo.cs
- ConfigXmlElement.cs
- ConfigurationPropertyCollection.cs
- ControlType.cs
- ValidationRule.cs
- LockRenewalTask.cs
- InfoCardAsymmetricCrypto.cs
- SynthesizerStateChangedEventArgs.cs
- WebPartEditorCancelVerb.cs
- ListViewItem.cs
- DecoderFallbackWithFailureFlag.cs
- ImageMap.cs
- WindowInteropHelper.cs
- ContractMapping.cs
- BufferModesCollection.cs
- ChtmlMobileTextWriter.cs
- SubqueryRules.cs
- EndPoint.cs
- UserControlCodeDomTreeGenerator.cs
- SharedPerformanceCounter.cs
- XPathNavigatorKeyComparer.cs
- SqlError.cs
- StreamGeometry.cs
- SecurityContext.cs
- SqlCommandSet.cs
- SendMailErrorEventArgs.cs
- ManipulationLogic.cs
- AppSettingsExpressionBuilder.cs
- PropertyMetadata.cs
- DataObjectPastingEventArgs.cs
- ConstraintEnumerator.cs
- CalendarItem.cs