Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / xsp / System / Web / UI / WebParts / WebPartVerb.cs / 1 / WebPartVerb.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls.WebParts { using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing.Design; using System.Globalization; using System.Security.Permissions; using System.Web.UI.WebControls; using System.Web.Util; [ TypeConverter(typeof(EmptyStringExpandableObjectConverter)) ] [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class WebPartVerb : IStateManager { private bool _isTrackingViewState; private StateBag _viewState; private bool _visible = true; private string _id; private string _clientClickHandler; private WebPartEventHandler _serverClickHandler; private string _eventArgument; // PERF: Don't create the EventArgument string until needed, when the verb is actually rendered. private string _eventArgumentPrefix; // Used when creating default verbs in WebPartZoneBase, CatalogZoneBase, EditorZoneBase. For these // verbs, the clientClickHandler and serverClickHandler are null. The zone has references // to these verbs and can render the verb and handle events by knowing which verb it is // rendering. internal WebPartVerb() { } private WebPartVerb(string id) { if (String.IsNullOrEmpty(id)) { throw ExceptionUtil.ParameterNullOrEmpty("id"); } _id = id; } public WebPartVerb(string id, WebPartEventHandler serverClickHandler) : this(id) { if (serverClickHandler == null) { throw new ArgumentNullException("serverClickHandler"); } _serverClickHandler = serverClickHandler; } public WebPartVerb(string id, string clientClickHandler) : this(id) { if (String.IsNullOrEmpty(clientClickHandler)) { throw new ArgumentNullException("clientClickHandler"); } _clientClickHandler = clientClickHandler; } public WebPartVerb(string id, WebPartEventHandler serverClickHandler, string clientClickHandler) : this(id) { if (serverClickHandler == null) { throw new ArgumentNullException("serverClickHandler"); } if (String.IsNullOrEmpty(clientClickHandler)) { throw new ArgumentNullException("clientClickHandler"); } _serverClickHandler = serverClickHandler; _clientClickHandler = clientClickHandler; } [ DefaultValue(false), NotifyParentProperty(true), Themeable(false), WebSysDescription(SR.WebPartVerb_Checked), ] public virtual bool Checked { get { object b = ViewState["Checked"]; return (b != null) ? (bool)b : false ; } set { ViewState["Checked"] = value; } } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) ] public string ClientClickHandler { get { return (_clientClickHandler == null) ? String.Empty: _clientClickHandler; } } [ Localizable(true), NotifyParentProperty(true), // Must use WebSysDefaultValue instead of DefaultValue, since it is overridden in extending classes WebSysDefaultValue(""), WebSysDescription(SR.WebPartVerb_Description), ] public virtual string Description { get { object o = ViewState["Description"]; return (o == null) ? String.Empty : (string)o; } set { ViewState["Description"] = value; } } [ DefaultValue(true), NotifyParentProperty(true), Themeable(false), WebSysDescription(SR.WebPartVerb_Enabled), ] public virtual bool Enabled { get { object b = ViewState["Enabled"]; return (b != null) ? (bool)b : true; } set { ViewState["Enabled"] = value; } } ////// Used to assign an event argument to the verb that will be rendered later. /// internal string EventArgument { get { return (_eventArgument != null) ? _eventArgument : String.Empty; } set { _eventArgument = value; } } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) ] public string ID { get { return (_id != null) ? _id : String.Empty; } } [ DefaultValue(""), Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)), NotifyParentProperty(true), UrlProperty(), WebSysDescription(SR.WebPartVerb_ImageUrl), ] public virtual string ImageUrl { get { object o = ViewState["ImageUrl"]; return (o == null) ? String.Empty : (string)o; } set { ViewState["ImageUrl"] = value; } } protected virtual bool IsTrackingViewState { get { return _isTrackingViewState; } } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) ] public WebPartEventHandler ServerClickHandler { get { return _serverClickHandler; } } ////// The text to be displayed for the webPartVerb. /// [ Localizable(true), NotifyParentProperty(true), // Must use WebSysDefaultValue instead of DefaultValue, since it is overridden in extending classes WebSysDefaultValue(""), WebSysDescription(SR.WebPartVerb_Text), ] public virtual string Text { get { object o = ViewState["Text"]; return (o == null) ? String.Empty : (string)o; } set { ViewState["Text"] = value; } } [ DefaultValue(true), NotifyParentProperty(true), Themeable(false), WebSysDescription(SR.WebPartVerb_Visible), ] public virtual bool Visible { get { return _visible; } set { _visible = value; ViewState["Visible"] = value; } } protected StateBag ViewState { get { if (_viewState == null) { _viewState = new StateBag(false); if (_isTrackingViewState) { ((IStateManager)_viewState).TrackViewState(); } } return _viewState; } } // PERF: Don't create the EventArgument string until needed, when the verb is actually rendered. // Only called by WebPartChrome and WebPartMenu. The verbs in CatalogZone, EditorZone, and // ConnectionsZone just use the EventArgument property. internal string GetEventArgument(string webPartID) { // If the prefix was never set, it means we are a user-specified verb with only a // client click handler. So we should return String.Empty for our EventArgument. if (String.IsNullOrEmpty(_eventArgumentPrefix)) { return String.Empty; } else { if (_id == null) { return _eventArgumentPrefix + webPartID; } else { return _eventArgumentPrefix + _id + WebPartZoneBase.EventArgumentSeparator + webPartID; } } } protected virtual void LoadViewState(object savedState) { if (savedState != null) { ((IStateManager)ViewState).LoadViewState(savedState); // Cache value of Visible object b = ViewState["Visible"]; if (b != null) { _visible = (bool)b; } } } protected virtual object SaveViewState() { if (_viewState != null) { return ((IStateManager)_viewState).SaveViewState(); } return null; } // Only used by WebPartZoneBase for verbs rendered on a WebPart. internal void SetEventArgumentPrefix(string eventArgumentPrefix) { _eventArgumentPrefix = eventArgumentPrefix; } protected virtual void TrackViewState() { _isTrackingViewState = true; if (_viewState != null) { ((IStateManager)_viewState).TrackViewState(); } } #region Implementation of IStateManager ///bool IStateManager.IsTrackingViewState { get { return IsTrackingViewState; } } /// void IStateManager.LoadViewState(object savedState) { LoadViewState(savedState); } /// object IStateManager.SaveViewState() { return SaveViewState(); } /// void IStateManager.TrackViewState() { TrackViewState(); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls.WebParts { using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing.Design; using System.Globalization; using System.Security.Permissions; using System.Web.UI.WebControls; using System.Web.Util; [ TypeConverter(typeof(EmptyStringExpandableObjectConverter)) ] [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class WebPartVerb : IStateManager { private bool _isTrackingViewState; private StateBag _viewState; private bool _visible = true; private string _id; private string _clientClickHandler; private WebPartEventHandler _serverClickHandler; private string _eventArgument; // PERF: Don't create the EventArgument string until needed, when the verb is actually rendered. private string _eventArgumentPrefix; // Used when creating default verbs in WebPartZoneBase, CatalogZoneBase, EditorZoneBase. For these // verbs, the clientClickHandler and serverClickHandler are null. The zone has references // to these verbs and can render the verb and handle events by knowing which verb it is // rendering. internal WebPartVerb() { } private WebPartVerb(string id) { if (String.IsNullOrEmpty(id)) { throw ExceptionUtil.ParameterNullOrEmpty("id"); } _id = id; } public WebPartVerb(string id, WebPartEventHandler serverClickHandler) : this(id) { if (serverClickHandler == null) { throw new ArgumentNullException("serverClickHandler"); } _serverClickHandler = serverClickHandler; } public WebPartVerb(string id, string clientClickHandler) : this(id) { if (String.IsNullOrEmpty(clientClickHandler)) { throw new ArgumentNullException("clientClickHandler"); } _clientClickHandler = clientClickHandler; } public WebPartVerb(string id, WebPartEventHandler serverClickHandler, string clientClickHandler) : this(id) { if (serverClickHandler == null) { throw new ArgumentNullException("serverClickHandler"); } if (String.IsNullOrEmpty(clientClickHandler)) { throw new ArgumentNullException("clientClickHandler"); } _serverClickHandler = serverClickHandler; _clientClickHandler = clientClickHandler; } [ DefaultValue(false), NotifyParentProperty(true), Themeable(false), WebSysDescription(SR.WebPartVerb_Checked), ] public virtual bool Checked { get { object b = ViewState["Checked"]; return (b != null) ? (bool)b : false ; } set { ViewState["Checked"] = value; } } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) ] public string ClientClickHandler { get { return (_clientClickHandler == null) ? String.Empty: _clientClickHandler; } } [ Localizable(true), NotifyParentProperty(true), // Must use WebSysDefaultValue instead of DefaultValue, since it is overridden in extending classes WebSysDefaultValue(""), WebSysDescription(SR.WebPartVerb_Description), ] public virtual string Description { get { object o = ViewState["Description"]; return (o == null) ? String.Empty : (string)o; } set { ViewState["Description"] = value; } } [ DefaultValue(true), NotifyParentProperty(true), Themeable(false), WebSysDescription(SR.WebPartVerb_Enabled), ] public virtual bool Enabled { get { object b = ViewState["Enabled"]; return (b != null) ? (bool)b : true; } set { ViewState["Enabled"] = value; } } ////// Used to assign an event argument to the verb that will be rendered later. /// internal string EventArgument { get { return (_eventArgument != null) ? _eventArgument : String.Empty; } set { _eventArgument = value; } } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) ] public string ID { get { return (_id != null) ? _id : String.Empty; } } [ DefaultValue(""), Editor("System.Web.UI.Design.ImageUrlEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor)), NotifyParentProperty(true), UrlProperty(), WebSysDescription(SR.WebPartVerb_ImageUrl), ] public virtual string ImageUrl { get { object o = ViewState["ImageUrl"]; return (o == null) ? String.Empty : (string)o; } set { ViewState["ImageUrl"] = value; } } protected virtual bool IsTrackingViewState { get { return _isTrackingViewState; } } [ Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden) ] public WebPartEventHandler ServerClickHandler { get { return _serverClickHandler; } } ////// The text to be displayed for the webPartVerb. /// [ Localizable(true), NotifyParentProperty(true), // Must use WebSysDefaultValue instead of DefaultValue, since it is overridden in extending classes WebSysDefaultValue(""), WebSysDescription(SR.WebPartVerb_Text), ] public virtual string Text { get { object o = ViewState["Text"]; return (o == null) ? String.Empty : (string)o; } set { ViewState["Text"] = value; } } [ DefaultValue(true), NotifyParentProperty(true), Themeable(false), WebSysDescription(SR.WebPartVerb_Visible), ] public virtual bool Visible { get { return _visible; } set { _visible = value; ViewState["Visible"] = value; } } protected StateBag ViewState { get { if (_viewState == null) { _viewState = new StateBag(false); if (_isTrackingViewState) { ((IStateManager)_viewState).TrackViewState(); } } return _viewState; } } // PERF: Don't create the EventArgument string until needed, when the verb is actually rendered. // Only called by WebPartChrome and WebPartMenu. The verbs in CatalogZone, EditorZone, and // ConnectionsZone just use the EventArgument property. internal string GetEventArgument(string webPartID) { // If the prefix was never set, it means we are a user-specified verb with only a // client click handler. So we should return String.Empty for our EventArgument. if (String.IsNullOrEmpty(_eventArgumentPrefix)) { return String.Empty; } else { if (_id == null) { return _eventArgumentPrefix + webPartID; } else { return _eventArgumentPrefix + _id + WebPartZoneBase.EventArgumentSeparator + webPartID; } } } protected virtual void LoadViewState(object savedState) { if (savedState != null) { ((IStateManager)ViewState).LoadViewState(savedState); // Cache value of Visible object b = ViewState["Visible"]; if (b != null) { _visible = (bool)b; } } } protected virtual object SaveViewState() { if (_viewState != null) { return ((IStateManager)_viewState).SaveViewState(); } return null; } // Only used by WebPartZoneBase for verbs rendered on a WebPart. internal void SetEventArgumentPrefix(string eventArgumentPrefix) { _eventArgumentPrefix = eventArgumentPrefix; } protected virtual void TrackViewState() { _isTrackingViewState = true; if (_viewState != null) { ((IStateManager)_viewState).TrackViewState(); } } #region Implementation of IStateManager ///bool IStateManager.IsTrackingViewState { get { return IsTrackingViewState; } } /// void IStateManager.LoadViewState(object savedState) { LoadViewState(savedState); } /// object IStateManager.SaveViewState() { return SaveViewState(); } /// void IStateManager.TrackViewState() { TrackViewState(); } #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
- EntityProxyFactory.cs
- HorizontalAlignConverter.cs
- VolatileResourceManager.cs
- COAUTHIDENTITY.cs
- ToolStripContextMenu.cs
- LZCodec.cs
- AmbientLight.cs
- Light.cs
- ToolStripSplitStackLayout.cs
- ActivityDesignerLayoutSerializers.cs
- FileAuthorizationModule.cs
- NavigationFailedEventArgs.cs
- Environment.cs
- Exceptions.cs
- PointCollection.cs
- XmlSchemaSubstitutionGroup.cs
- KoreanLunisolarCalendar.cs
- PropertyConverter.cs
- CancellationState.cs
- ResourceContainer.cs
- DocumentPageHost.cs
- XsdBuildProvider.cs
- CompositeTypefaceMetrics.cs
- PathFigureCollectionValueSerializer.cs
- StrokeNodeOperations.cs
- SerializationAttributes.cs
- SmtpReplyReaderFactory.cs
- PointAnimation.cs
- DataGridViewColumnStateChangedEventArgs.cs
- TimestampInformation.cs
- CachedBitmap.cs
- MdiWindowListItemConverter.cs
- CmsInterop.cs
- WebServiceEndpoint.cs
- ControlBuilder.cs
- DBNull.cs
- ConnectionStringEditor.cs
- HitTestWithPointDrawingContextWalker.cs
- ProtectedUri.cs
- SettingsPropertyNotFoundException.cs
- WeakReferenceKey.cs
- DataGridColumnFloatingHeader.cs
- CommandEventArgs.cs
- ToolStripPanelRenderEventArgs.cs
- PassportAuthenticationModule.cs
- ActivityTypeDesigner.xaml.cs
- InstanceNormalEvent.cs
- SchemaEntity.cs
- TextElementCollectionHelper.cs
- ComboBoxRenderer.cs
- Italic.cs
- RelationshipFixer.cs
- ConfigUtil.cs
- WebPartConnection.cs
- AppLevelCompilationSectionCache.cs
- FixedTextSelectionProcessor.cs
- MouseActionConverter.cs
- VirtualDirectoryMapping.cs
- ImagingCache.cs
- RSAPKCS1KeyExchangeFormatter.cs
- DataRecord.cs
- DataGridCellInfo.cs
- IOException.cs
- LinearKeyFrames.cs
- RecognitionEventArgs.cs
- DbConnectionStringCommon.cs
- EncryptedData.cs
- SchemaObjectWriter.cs
- MissingFieldException.cs
- PerformanceCountersElement.cs
- ThicknessAnimationBase.cs
- AsymmetricKeyExchangeDeformatter.cs
- FormatterServices.cs
- IPHostEntry.cs
- RequestBringIntoViewEventArgs.cs
- GlyphRunDrawing.cs
- OleDbException.cs
- DataGridViewCellFormattingEventArgs.cs
- DbModificationClause.cs
- AmbientValueAttribute.cs
- InputLanguageSource.cs
- DeviceFilterEditorDialog.cs
- XmlSchemaInclude.cs
- ApplicationTrust.cs
- SmiContext.cs
- FastEncoder.cs
- HttpCookiesSection.cs
- CfgSemanticTag.cs
- WindowsMenu.cs
- ThemeableAttribute.cs
- UndoEngine.cs
- HyperLinkField.cs
- Mutex.cs
- complextypematerializer.cs
- SessionState.cs
- LayoutTableCell.cs
- PropertyChangedEventArgs.cs
- QilReplaceVisitor.cs
- PrintPreviewDialog.cs
- TextServicesPropertyRanges.cs