Code:
/ 4.0 / 4.0 / 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. 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
- Window.cs
- BCLDebug.cs
- DrawListViewItemEventArgs.cs
- DecoderFallback.cs
- Tag.cs
- PrincipalPermission.cs
- TableColumnCollectionInternal.cs
- DictionarySurrogate.cs
- SqlDataReader.cs
- ToolStripPanel.cs
- UserControlDocumentDesigner.cs
- InitializerFacet.cs
- entitydatasourceentitysetnameconverter.cs
- HwndMouseInputProvider.cs
- NotFiniteNumberException.cs
- DataGridTable.cs
- DescriptionCreator.cs
- EntityDataSourceView.cs
- CustomCategoryAttribute.cs
- RichTextBoxContextMenu.cs
- EmptyEnumerable.cs
- Rotation3D.cs
- selecteditemcollection.cs
- CodeTypeOfExpression.cs
- SerializationEventsCache.cs
- StringToken.cs
- InvalidPropValue.cs
- SystemTcpConnection.cs
- InputReportEventArgs.cs
- Page.cs
- SafeNativeMethods.cs
- XslNumber.cs
- MemoryMappedViewStream.cs
- PromptEventArgs.cs
- DateTimePickerDesigner.cs
- ServiceChannelManager.cs
- StandardToolWindows.cs
- StylusPointDescription.cs
- XamlWriterExtensions.cs
- StorageComplexTypeMapping.cs
- ProcessHostMapPath.cs
- InvalidProgramException.cs
- Oci.cs
- SQLSingle.cs
- NetworkStream.cs
- ThemeableAttribute.cs
- InputMethodStateTypeInfo.cs
- StorageEndPropertyMapping.cs
- EventDescriptorCollection.cs
- PropertyMapper.cs
- ClientSettingsProvider.cs
- Control.cs
- RequestNavigateEventArgs.cs
- InstanceValue.cs
- FieldNameLookup.cs
- AsyncStreamReader.cs
- DataGridSortingEventArgs.cs
- SchemaImporterExtension.cs
- ExceptionUtil.cs
- SecurityElement.cs
- TableItemPattern.cs
- KeyValueSerializer.cs
- UInt16Converter.cs
- WebRequestModulesSection.cs
- TraceHandlerErrorFormatter.cs
- UIElement.cs
- DoubleUtil.cs
- DragDrop.cs
- Token.cs
- ProcessInfo.cs
- ContentPropertyAttribute.cs
- VirtualizingStackPanel.cs
- DataGridColumn.cs
- JpegBitmapEncoder.cs
- StreamGeometry.cs
- ReadOnlyCollection.cs
- PartBasedPackageProperties.cs
- TabItem.cs
- FormsIdentity.cs
- TextTreeTextNode.cs
- CFStream.cs
- ProviderConnectionPoint.cs
- DLinqAssociationProvider.cs
- CultureSpecificCharacterBufferRange.cs
- XmlSubtreeReader.cs
- Vector3DAnimationUsingKeyFrames.cs
- Convert.cs
- CapabilitiesAssignment.cs
- MDIControlStrip.cs
- CodeTypeDeclarationCollection.cs
- GradientStop.cs
- GenericsInstances.cs
- SwitchLevelAttribute.cs
- MachineKeyValidationConverter.cs
- ReaderContextStackData.cs
- _ListenerResponseStream.cs
- OdbcConnection.cs
- WebDisplayNameAttribute.cs
- ConsumerConnectionPointCollection.cs
- SHA256Managed.cs