Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / xsp / System / Web / Extensions / ui / UpdateProgress.cs / 2 / UpdateProgress.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Globalization; using System.Security.Permissions; using System.Text; using System.Web; using System.Web.UI; using System.Web.Script; using System.Web.Resources; using System.Web.Util; [ AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("AssociatedUpdatePanelID"), Designer("System.Web.UI.Design.UpdateProgressDesigner, " + AssemblyRef.SystemWebExtensionsDesign), ParseChildren(true), PersistChildren(false), ToolboxBitmap(typeof(EmbeddedResourceFinder), "System.Web.Resources.UpdateProgress.bmp"), ToolboxItemFilterAttribute(AssemblyRef.SystemWebExtensions, ToolboxItemFilterType.Require), ] public class UpdateProgress : Control, IScriptControl { private ITemplate _progressTemplate; private Control _progressTemplateContainer; private int _displayAfter = 500; private bool _dynamicLayout = true; private string _associatedUpdatePanelID; [ Category("Behavior"), DefaultValue(""), IDReferenceProperty(typeof(UpdatePanel)), ResourceDescription("UpdateProgress_AssociatedUpdatePanelID"), SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID"), TypeConverter("System.Web.UI.Design.UpdateProgressAssociatedUpdatePanelIDConverter") ] public string AssociatedUpdatePanelID { get { if (_associatedUpdatePanelID == null) { return String.Empty; } return _associatedUpdatePanelID; } set { _associatedUpdatePanelID = value; } } public override ControlCollection Controls { get { EnsureChildControls(); return base.Controls; } } [ DefaultValue(500), ResourceDescription("UpdateProgress_DisplayAfter"), Category("Behavior") ] public int DisplayAfter { get { return _displayAfter; } set { if (value < 0) { throw new ArgumentOutOfRangeException(AtlasWeb.UpdateProgress_DisplayAfterInvalid); } _displayAfter = value; } } [ Browsable(false), PersistenceMode(PersistenceMode.InnerProperty), ResourceDescription("UpdateProgress_ProgressTemplate"), ] public ITemplate ProgressTemplate { get { return _progressTemplate; } set { _progressTemplate = value; } } [ DefaultValue(true), ResourceDescription("UpdateProgress_DynamicLayout"), Category("Behavior") ] public bool DynamicLayout { get { return _dynamicLayout; } set { _dynamicLayout = value; } } private ScriptManager ScriptManager { get { ScriptManager scriptManager = ScriptManager.GetCurrent(Page); if (scriptManager == null) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.Common_ScriptManagerRequired, ID)); } return scriptManager; } } protected internal override void CreateChildControls() { // Set up the progress template if (!DesignMode && _progressTemplate == null) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.UpdateProgress_TemplateRequired, ID)); } else if (_progressTemplate != null) { _progressTemplateContainer = new Control(); _progressTemplate.InstantiateIn(_progressTemplateContainer); Controls.Add(_progressTemplateContainer); } } public override void DataBind() { EnsureChildControls(); base.DataBind(); } [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")] protected internal override void OnPreRender(EventArgs e) { base.OnPreRender(e); ScriptManager.RegisterScriptControl(this); } protected internal override void Render(HtmlTextWriter writer) { EnsureChildControls(); writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID); if (_dynamicLayout) { writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); } else { writer.AddStyleAttribute(HtmlTextWriterStyle.Visibility, "hidden"); writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "block"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); base.Render(writer); writer.RenderEndTag(); // div if (!DesignMode) { ScriptManager.RegisterScriptDescriptors(this); } } [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Matches IScriptControl interface.")] protected virtual IEnumerableGetScriptReferences() { yield break; } [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Matches IScriptControl interface.")] protected virtual IEnumerable GetScriptDescriptors() { // Don't render any scripts when partial rendering is not enabled if (Page != null && ScriptManager.SupportsPartialRendering && Visible) { ScriptControlDescriptor desc = new ScriptControlDescriptor("Sys.UI._UpdateProgress", ClientID); string updatePanelClientID = null; if (!String.IsNullOrEmpty(AssociatedUpdatePanelID)) { // Try both the NamingContainer and the Page UpdatePanel c = ControlUtil.FindTargetControl(AssociatedUpdatePanelID, this, true) as UpdatePanel; if (c != null) updatePanelClientID = c.ClientID; else { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.UpdateProgress_NoUpdatePanel, AssociatedUpdatePanelID)); } } desc.AddProperty("associatedUpdatePanelId", updatePanelClientID); desc.AddProperty("dynamicLayout", DynamicLayout); desc.AddProperty("displayAfter", DisplayAfter); yield return desc; } yield break; } #region IScriptControl Members IEnumerable IScriptControl.GetScriptReferences() { return GetScriptReferences(); } IEnumerable IScriptControl.GetScriptDescriptors() { return GetScriptDescriptors(); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI { using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.Globalization; using System.Security.Permissions; using System.Text; using System.Web; using System.Web.UI; using System.Web.Script; using System.Web.Resources; using System.Web.Util; [ AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), DefaultProperty("AssociatedUpdatePanelID"), Designer("System.Web.UI.Design.UpdateProgressDesigner, " + AssemblyRef.SystemWebExtensionsDesign), ParseChildren(true), PersistChildren(false), ToolboxBitmap(typeof(EmbeddedResourceFinder), "System.Web.Resources.UpdateProgress.bmp"), ToolboxItemFilterAttribute(AssemblyRef.SystemWebExtensions, ToolboxItemFilterType.Require), ] public class UpdateProgress : Control, IScriptControl { private ITemplate _progressTemplate; private Control _progressTemplateContainer; private int _displayAfter = 500; private bool _dynamicLayout = true; private string _associatedUpdatePanelID; [ Category("Behavior"), DefaultValue(""), IDReferenceProperty(typeof(UpdatePanel)), ResourceDescription("UpdateProgress_AssociatedUpdatePanelID"), SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ID"), TypeConverter("System.Web.UI.Design.UpdateProgressAssociatedUpdatePanelIDConverter") ] public string AssociatedUpdatePanelID { get { if (_associatedUpdatePanelID == null) { return String.Empty; } return _associatedUpdatePanelID; } set { _associatedUpdatePanelID = value; } } public override ControlCollection Controls { get { EnsureChildControls(); return base.Controls; } } [ DefaultValue(500), ResourceDescription("UpdateProgress_DisplayAfter"), Category("Behavior") ] public int DisplayAfter { get { return _displayAfter; } set { if (value < 0) { throw new ArgumentOutOfRangeException(AtlasWeb.UpdateProgress_DisplayAfterInvalid); } _displayAfter = value; } } [ Browsable(false), PersistenceMode(PersistenceMode.InnerProperty), ResourceDescription("UpdateProgress_ProgressTemplate"), ] public ITemplate ProgressTemplate { get { return _progressTemplate; } set { _progressTemplate = value; } } [ DefaultValue(true), ResourceDescription("UpdateProgress_DynamicLayout"), Category("Behavior") ] public bool DynamicLayout { get { return _dynamicLayout; } set { _dynamicLayout = value; } } private ScriptManager ScriptManager { get { ScriptManager scriptManager = ScriptManager.GetCurrent(Page); if (scriptManager == null) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.Common_ScriptManagerRequired, ID)); } return scriptManager; } } protected internal override void CreateChildControls() { // Set up the progress template if (!DesignMode && _progressTemplate == null) { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.UpdateProgress_TemplateRequired, ID)); } else if (_progressTemplate != null) { _progressTemplateContainer = new Control(); _progressTemplate.InstantiateIn(_progressTemplateContainer); Controls.Add(_progressTemplateContainer); } } public override void DataBind() { EnsureChildControls(); base.DataBind(); } [SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")] protected internal override void OnPreRender(EventArgs e) { base.OnPreRender(e); ScriptManager.RegisterScriptControl(this); } protected internal override void Render(HtmlTextWriter writer) { EnsureChildControls(); writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID); if (_dynamicLayout) { writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); } else { writer.AddStyleAttribute(HtmlTextWriterStyle.Visibility, "hidden"); writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "block"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); base.Render(writer); writer.RenderEndTag(); // div if (!DesignMode) { ScriptManager.RegisterScriptDescriptors(this); } } [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Matches IScriptControl interface.")] protected virtual IEnumerableGetScriptReferences() { yield break; } [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Matches IScriptControl interface.")] protected virtual IEnumerable GetScriptDescriptors() { // Don't render any scripts when partial rendering is not enabled if (Page != null && ScriptManager.SupportsPartialRendering && Visible) { ScriptControlDescriptor desc = new ScriptControlDescriptor("Sys.UI._UpdateProgress", ClientID); string updatePanelClientID = null; if (!String.IsNullOrEmpty(AssociatedUpdatePanelID)) { // Try both the NamingContainer and the Page UpdatePanel c = ControlUtil.FindTargetControl(AssociatedUpdatePanelID, this, true) as UpdatePanel; if (c != null) updatePanelClientID = c.ClientID; else { throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, AtlasWeb.UpdateProgress_NoUpdatePanel, AssociatedUpdatePanelID)); } } desc.AddProperty("associatedUpdatePanelId", updatePanelClientID); desc.AddProperty("dynamicLayout", DynamicLayout); desc.AddProperty("displayAfter", DisplayAfter); yield return desc; } yield break; } #region IScriptControl Members IEnumerable IScriptControl.GetScriptReferences() { return GetScriptReferences(); } IEnumerable IScriptControl.GetScriptDescriptors() { return GetScriptDescriptors(); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WindowsToolbar.cs
- OleDbInfoMessageEvent.cs
- GlobalizationAssembly.cs
- ContentDisposition.cs
- CellParagraph.cs
- SystemGatewayIPAddressInformation.cs
- MethodCallTranslator.cs
- GridViewCommandEventArgs.cs
- ApplicationHost.cs
- DSACryptoServiceProvider.cs
- ArrangedElementCollection.cs
- HtmlInputText.cs
- BoundsDrawingContextWalker.cs
- GridViewSelectEventArgs.cs
- AppDomainProtocolHandler.cs
- DataGridColumnCollection.cs
- SqlMultiplexer.cs
- InheritanceContextChangedEventManager.cs
- ProcessThreadCollection.cs
- TypefaceMap.cs
- Rotation3DAnimationBase.cs
- DataGridCommandEventArgs.cs
- RemoteDebugger.cs
- SettingsPropertyIsReadOnlyException.cs
- Control.cs
- PackagePart.cs
- OuterProxyWrapper.cs
- PrimarySelectionAdorner.cs
- TickBar.cs
- Section.cs
- WindowInteropHelper.cs
- QilCloneVisitor.cs
- AttributeEmitter.cs
- ActiveXContainer.cs
- InputLanguageProfileNotifySink.cs
- ColorContextHelper.cs
- KeyInfo.cs
- LinearQuaternionKeyFrame.cs
- MenuBase.cs
- PublisherMembershipCondition.cs
- MaskDescriptor.cs
- SspiSecurityTokenProvider.cs
- UserPersonalizationStateInfo.cs
- FontNameConverter.cs
- InputProcessorProfiles.cs
- XmlAnyElementAttributes.cs
- SelectionProcessor.cs
- EnumMemberAttribute.cs
- ProxyWebPartConnectionCollection.cs
- ExternalException.cs
- LocalizationComments.cs
- HandleCollector.cs
- ProcessProtocolHandler.cs
- GradientStop.cs
- NGCSerializationManager.cs
- PageHandlerFactory.cs
- KeyTime.cs
- SqlStatistics.cs
- SpecularMaterial.cs
- ServiceMetadataContractBehavior.cs
- PropertyItemInternal.cs
- CriticalFinalizerObject.cs
- DesignerActionTextItem.cs
- TypedTableGenerator.cs
- VirtualizedCellInfoCollection.cs
- StateWorkerRequest.cs
- EventMappingSettings.cs
- MemberDomainMap.cs
- GrammarBuilder.cs
- formatstringdialog.cs
- TransactionManager.cs
- BaseDataListDesigner.cs
- SafeRightsManagementSessionHandle.cs
- EntityContainerEmitter.cs
- WmlCalendarAdapter.cs
- FormsAuthenticationCredentials.cs
- PagedDataSource.cs
- EditingCommands.cs
- MaskedTextProvider.cs
- ListControl.cs
- VectorAnimationBase.cs
- UIAgentAsyncParams.cs
- CellTreeNode.cs
- WorkItem.cs
- Bitmap.cs
- GeneralTransformCollection.cs
- PersistenceTypeAttribute.cs
- XmlSchemaAppInfo.cs
- ManipulationBoundaryFeedbackEventArgs.cs
- DLinqDataModelProvider.cs
- HttpStreamXmlDictionaryReader.cs
- COM2TypeInfoProcessor.cs
- HttpSysSettings.cs
- UIElement.cs
- BindingContext.cs
- AffineTransform3D.cs
- AddInSegmentDirectoryNotFoundException.cs
- ModifiableIteratorCollection.cs
- XsltLoader.cs
- TransformGroup.cs