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
- EntityDataSourceStatementEditorForm.cs
- ObjectStateManager.cs
- FillRuleValidation.cs
- RuntimeConfig.cs
- ObjectConverter.cs
- ContractTypeNameElement.cs
- NameObjectCollectionBase.cs
- CellParaClient.cs
- HttpHandlerAction.cs
- QilXmlReader.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- ListBoxItemWrapperAutomationPeer.cs
- ProxyWebPart.cs
- Object.cs
- SspiSecurityTokenParameters.cs
- DbExpressionBuilder.cs
- TextParagraph.cs
- GenerateHelper.cs
- Page.cs
- AlternateViewCollection.cs
- WinEventQueueItem.cs
- ItemContainerGenerator.cs
- ConnectionStringsExpressionBuilder.cs
- NumberFunctions.cs
- SizeConverter.cs
- SID.cs
- RepeaterItemEventArgs.cs
- MULTI_QI.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- Compiler.cs
- TypeConverter.cs
- SourceLineInfo.cs
- oledbmetadatacolumnnames.cs
- ComponentEditorForm.cs
- UserControl.cs
- ChannelManagerService.cs
- SemaphoreSecurity.cs
- DataGridViewTopLeftHeaderCell.cs
- EventLogPermissionEntryCollection.cs
- UndoUnit.cs
- TextOptions.cs
- ProcessHostFactoryHelper.cs
- Bold.cs
- TimeSpanConverter.cs
- PassportIdentity.cs
- Int32CAMarshaler.cs
- EditorPart.cs
- FormViewDeleteEventArgs.cs
- SplitterEvent.cs
- ConfigurationPropertyAttribute.cs
- TraversalRequest.cs
- OperatingSystem.cs
- Wizard.cs
- Soap12ProtocolReflector.cs
- DataBindingCollection.cs
- DocumentViewerHelper.cs
- OledbConnectionStringbuilder.cs
- CodeTryCatchFinallyStatement.cs
- DataServiceStreamResponse.cs
- OdbcConnectionOpen.cs
- TableColumnCollection.cs
- HttpSocketManager.cs
- TopClause.cs
- SoapMessage.cs
- SizeAnimationBase.cs
- GridViewColumnHeaderAutomationPeer.cs
- DBSqlParserTable.cs
- ViewValidator.cs
- DirectoryRedirect.cs
- ConnectionInterfaceCollection.cs
- IPEndPoint.cs
- DesignerSerializerAttribute.cs
- Types.cs
- VarRemapper.cs
- EventSinkHelperWriter.cs
- SecurityManager.cs
- SyndicationDeserializer.cs
- Selection.cs
- NotSupportedException.cs
- InkCanvasSelection.cs
- _HeaderInfoTable.cs
- Document.cs
- NetNamedPipeBindingElement.cs
- DuplicateContext.cs
- SqlWebEventProvider.cs
- UnionQueryOperator.cs
- StringConverter.cs
- TextBox.cs
- HtmlEncodedRawTextWriter.cs
- GroupedContextMenuStrip.cs
- ButtonFlatAdapter.cs
- WindowsSecurityToken.cs
- metrodevice.cs
- XPathSelfQuery.cs
- ImagingCache.cs
- DesigntimeLicenseContextSerializer.cs
- AuthenticationService.cs
- ManagedCodeMarkers.cs
- ErrorEventArgs.cs
- ThreadExceptionEvent.cs