当前位置: 首页>>代码示例>>C#>>正文


C# WebPart.ToControl方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.WebParts.WebPart.ToControl方法的典型用法代码示例。如果您正苦于以下问题:C# WebPart.ToControl方法的具体用法?C# WebPart.ToControl怎么用?C# WebPart.ToControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.WebParts.WebPart的用法示例。


在下文中一共展示了WebPart.ToControl方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetProviderConnectionPoints

 public virtual ProviderConnectionPointCollection GetProviderConnectionPoints(WebPart webPart)
 {
     if (webPart == null)
     {
         throw new ArgumentNullException("webPart");
     }
     return GetProviderConnectionPoints(webPart.ToControl().GetType());
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:WebPartManager.cs

示例2: CanConnectWebPartsCore

 private bool CanConnectWebPartsCore(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartTransformer transformer, bool throwOnError)
 {
     if (!this.Personalization.IsModifiable)
     {
         if (!throwOnError)
         {
             return false;
         }
         this.Personalization.EnsureEnabled(true);
     }
     if (provider == null)
     {
         throw new ArgumentNullException("provider");
     }
     if (!this.Controls.Contains(provider))
     {
         throw new ArgumentException(System.Web.SR.GetString("UnknownWebPart"), "provider");
     }
     if (consumer == null)
     {
         throw new ArgumentNullException("consumer");
     }
     if (!this.Controls.Contains(consumer))
     {
         throw new ArgumentException(System.Web.SR.GetString("UnknownWebPart"), "consumer");
     }
     if (providerConnectionPoint == null)
     {
         throw new ArgumentNullException("providerConnectionPoint");
     }
     if (consumerConnectionPoint == null)
     {
         throw new ArgumentNullException("consumerConnectionPoint");
     }
     Control control = provider.ToControl();
     Control control2 = consumer.ToControl();
     if (providerConnectionPoint.ControlType != control.GetType())
     {
         throw new ArgumentException(System.Web.SR.GetString("WebPartManager_InvalidConnectionPoint"), "providerConnectionPoint");
     }
     if (consumerConnectionPoint.ControlType != control2.GetType())
     {
         throw new ArgumentException(System.Web.SR.GetString("WebPartManager_InvalidConnectionPoint"), "consumerConnectionPoint");
     }
     if (provider == consumer)
     {
         if (throwOnError)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartManager_CantConnectToSelf"));
         }
         return false;
     }
     if (provider.IsClosed)
     {
         if (throwOnError)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartManager_CantConnectClosed", new object[] { provider.ID }));
         }
         return false;
     }
     if (consumer.IsClosed)
     {
         if (throwOnError)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartManager_CantConnectClosed", new object[] { consumer.ID }));
         }
         return false;
     }
     if (!providerConnectionPoint.GetEnabled(control))
     {
         if (throwOnError)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_DisabledConnectionPoint", new object[] { providerConnectionPoint.ID, provider.ID }));
         }
         return false;
     }
     if (!consumerConnectionPoint.GetEnabled(control2))
     {
         if (throwOnError)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_DisabledConnectionPoint", new object[] { consumerConnectionPoint.ID, consumer.ID }));
         }
         return false;
     }
     if (!providerConnectionPoint.AllowsMultipleConnections)
     {
         foreach (WebPartConnection connection in this.Connections)
         {
             if ((connection.Provider == provider) && (connection.ProviderConnectionPoint == providerConnectionPoint))
             {
                 if (throwOnError)
                 {
                     throw new InvalidOperationException(System.Web.SR.GetString("WebPartConnection_Duplicate", new object[] { providerConnectionPoint.ID, provider.ID }));
                 }
                 return false;
             }
         }
     }
     if (!consumerConnectionPoint.AllowsMultipleConnections)
     {
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:WebPartManager.cs

示例3: ExportWebPart

 public virtual void ExportWebPart(WebPart webPart, XmlWriter writer)
 {
     if (webPart == null)
     {
         throw new ArgumentNullException("webPart");
     }
     if (!this.Controls.Contains(webPart))
     {
         throw new ArgumentException(System.Web.SR.GetString("UnknownWebPart"), "webPart");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (webPart.ExportMode == WebPartExportMode.None)
     {
         throw new ArgumentException(System.Web.SR.GetString("WebPartManager_PartNotExportable"), "webPart");
     }
     bool excludeSensitive = (webPart.ExportMode == WebPartExportMode.NonSensitiveData) && (this.Personalization.Scope != PersonalizationScope.Shared);
     writer.WriteStartElement("webParts");
     writer.WriteStartElement("webPart");
     writer.WriteAttributeString("xmlns", "http://schemas.microsoft.com/WebPart/v3");
     writer.WriteStartElement("metaData");
     writer.WriteStartElement("type");
     Control control = webPart.ToControl();
     UserControl control2 = control as UserControl;
     if (control2 != null)
     {
         writer.WriteAttributeString("src", control2.AppRelativeVirtualPath);
     }
     else
     {
         writer.WriteAttributeString("name", WebPartUtil.SerializeType(control.GetType()));
     }
     writer.WriteEndElement();
     writer.WriteElementString("importErrorMessage", webPart.ImportErrorMessage);
     writer.WriteEndElement();
     writer.WriteStartElement("data");
     IDictionary propBag = PersonalizableAttribute.GetPersonalizablePropertyValues(webPart, PersonalizationScope.Shared, excludeSensitive);
     writer.WriteStartElement("properties");
     if (webPart is GenericWebPart)
     {
         this.ExportIPersonalizable(writer, control, excludeSensitive);
         IDictionary dictionary2 = PersonalizableAttribute.GetPersonalizablePropertyValues(control, PersonalizationScope.Shared, excludeSensitive);
         this.ExportToWriter(dictionary2, writer);
         writer.WriteEndElement();
         writer.WriteStartElement("genericWebPartProperties");
         this.ExportIPersonalizable(writer, webPart, excludeSensitive);
         this.ExportToWriter(propBag, writer);
     }
     else
     {
         this.ExportIPersonalizable(writer, webPart, excludeSensitive);
         this.ExportToWriter(propBag, writer);
     }
     writer.WriteEndElement();
     writer.WriteEndElement();
     writer.WriteEndElement();
     writer.WriteEndElement();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:60,代码来源:WebPartManager.cs

示例4: GetEnabledConnectionPoints

 private static ICollection GetEnabledConnectionPoints(ICollection connectionPoints, WebPart webPart)
 {
     Control control = webPart.ToControl();
     ArrayList list = new ArrayList();
     foreach (ConnectionPoint point in connectionPoints)
     {
         if (point.GetEnabled(control))
         {
             list.Add(point);
         }
     }
     return list;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:WebPartManager.cs

示例5: ConnectWebParts

 public virtual WebPartConnection ConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint, WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint, WebPartTransformer transformer)
 {
     this.CanConnectWebPartsCore(provider, providerConnectionPoint, consumer, consumerConnectionPoint, transformer, true);
     if (this.DynamicConnections.IsReadOnly)
     {
         throw new InvalidOperationException(System.Web.SR.GetString("WebPartManager_ConnectTooLate"));
     }
     WebPartConnectionsCancelEventArgs e = new WebPartConnectionsCancelEventArgs(provider, providerConnectionPoint, consumer, consumerConnectionPoint);
     this.OnWebPartsConnecting(e);
     if (this._allowEventCancellation && e.Cancel)
     {
         return null;
     }
     Control control = provider.ToControl();
     Control control2 = consumer.ToControl();
     WebPartConnection connection = new WebPartConnection {
         ID = this.CreateDynamicConnectionID(),
         ProviderID = control.ID,
         ConsumerID = control2.ID,
         ProviderConnectionPointID = providerConnectionPoint.ID,
         ConsumerConnectionPointID = consumerConnectionPoint.ID
     };
     if (transformer != null)
     {
         this.Internals.SetTransformer(connection, transformer);
     }
     this.Internals.SetIsShared(connection, this.Personalization.Scope == PersonalizationScope.Shared);
     this.Internals.SetIsStatic(connection, false);
     this.DynamicConnections.Add(connection);
     this._hasDataChanged = true;
     this.OnWebPartsConnected(new WebPartConnectionsEventArgs(provider, providerConnectionPoint, consumer, consumerConnectionPoint, connection));
     return connection;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:WebPartManager.cs

示例6: GetProviderConnectionPoints

        public virtual ProviderConnectionPointCollection GetProviderConnectionPoints(WebPart webPart) {
            if (webPart == null) {
                throw new ArgumentNullException("webPart");
            }
            // Do not check that Controls.Contains(webPart), since this may be called on a WebPart
            // outside of a Zone.  Also, this method shouldn't really care whether the WebPart is
            // inside the WebPartManager.

            return GetProviderConnectionPoints(webPart.ToControl().GetType());
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:10,代码来源:WebPartManager.cs

示例7: ExportWebPart

        public virtual void ExportWebPart(WebPart webPart, XmlWriter writer) {
//            Personalization.EnsureEnabled(/* ensureModifiable */ false);

            if (webPart == null) {
                throw new ArgumentNullException("webPart");
            }
            if (!Controls.Contains(webPart)) {
                throw new ArgumentException(SR.GetString(SR.UnknownWebPart), "webPart");
            }

            if (writer == null) {
                throw new ArgumentNullException("writer");
            }
            if (webPart.ExportMode == WebPartExportMode.None) {
                throw new ArgumentException(SR.GetString(SR.WebPartManager_PartNotExportable), "webPart");
            }
            bool excludeSensitive = (webPart.ExportMode == WebPartExportMode.NonSensitiveData &&
                !(Personalization.Scope == PersonalizationScope.Shared));

            // Write the root elements
            writer.WriteStartElement(ExportRootElement);
            writer.WriteStartElement(ExportPartElement);
            writer.WriteAttributeString(ExportPartNamespaceAttribute, ExportPartNamespaceValue);
            // Write metadata
            writer.WriteStartElement(ExportMetaDataElement);
            writer.WriteStartElement(ExportTypeElement);
            Control control = webPart.ToControl();
            UserControl userControl = control as UserControl;
            if (userControl != null) {
                writer.WriteAttributeString(ExportUserControlSrcAttribute, userControl.AppRelativeVirtualPath);
            }
            else {
                writer.WriteAttributeString(ExportTypeNameAttribute, WebPartUtil.SerializeType(control.GetType()));
            }
            writer.WriteEndElement(); //type
            writer.WriteElementString(ExportErrorMessageElement, webPart.ImportErrorMessage);
            writer.WriteEndElement(); //metadata
            // Write the data
            writer.WriteStartElement(ExportDataElement);
            // We get the personalization data for the current page personalization mode
            IDictionary propBag = PersonalizableAttribute.GetPersonalizablePropertyValues(webPart, PersonalizationScope.Shared, excludeSensitive);

            writer.WriteStartElement(ExportPropertiesElement);

            // Special case GenericWebPart
            GenericWebPart genericWebPart = webPart as GenericWebPart;

            if (genericWebPart != null) {

                // Export IPersonalizable user control data first
                ExportIPersonalizable(writer, control, excludeSensitive);

                IDictionary controlData = PersonalizableAttribute.GetPersonalizablePropertyValues(control,
                                                                                                  PersonalizationScope.Shared,
                                                                                                  excludeSensitive);
                ExportToWriter(controlData, writer);
                writer.WriteEndElement(); //properties
                writer.WriteStartElement(ExportGenericPartPropertiesElement);
                // Export IPersonalizable part data first
                ExportIPersonalizable(writer, webPart, excludeSensitive);
                ExportToWriter(propBag, writer);
            }
            else {
                // Export IPersonalizable part data first
                ExportIPersonalizable(writer, webPart, excludeSensitive);
                ExportToWriter(propBag, writer);
            }
            writer.WriteEndElement(); //properties or genericWebPartProperties
            writer.WriteEndElement(); //data
            writer.WriteEndElement(); //webpart
            writer.WriteEndElement(); //webparts
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:72,代码来源:WebPartManager.cs

示例8: ConnectWebParts

        public virtual WebPartConnection ConnectWebParts(WebPart provider, ProviderConnectionPoint providerConnectionPoint,
                                                         WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint,
                                                         WebPartTransformer transformer) {
            CanConnectWebPartsCore(provider, providerConnectionPoint, consumer, consumerConnectionPoint,
                                   transformer, /*throwOnError*/ true);

            if (DynamicConnections.IsReadOnly) {
                throw new InvalidOperationException(SR.GetString(SR.WebPartManager_ConnectTooLate));
            }

            WebPartConnectionsCancelEventArgs ce = new WebPartConnectionsCancelEventArgs(
                provider, providerConnectionPoint, consumer, consumerConnectionPoint);
            OnWebPartsConnecting(ce);
            if (_allowEventCancellation && ce.Cancel) {
                return null;
            }

            Control providerControl = provider.ToControl();
            Control consumerControl = consumer.ToControl();

            WebPartConnection connection = new WebPartConnection();
            connection.ID = CreateDynamicConnectionID();
            connection.ProviderID = providerControl.ID;
            connection.ConsumerID = consumerControl.ID;
            connection.ProviderConnectionPointID = providerConnectionPoint.ID;
            connection.ConsumerConnectionPointID = consumerConnectionPoint.ID;

            if (transformer != null) {
                Internals.SetTransformer(connection, transformer);
            }

            Internals.SetIsShared(connection, Personalization.Scope == PersonalizationScope.Shared);
            Internals.SetIsStatic(connection, false);

            DynamicConnections.Add(connection);
            _hasDataChanged = true;

            OnWebPartsConnected(new WebPartConnectionsEventArgs(provider, providerConnectionPoint,
                                                                consumer, consumerConnectionPoint, connection));

            return connection;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:42,代码来源:WebPartManager.cs

示例9: CanConnectWebPartsCore

        private bool CanConnectWebPartsCore(WebPart provider, ProviderConnectionPoint providerConnectionPoint,
                                            WebPart consumer, ConsumerConnectionPoint consumerConnectionPoint,
                                            WebPartTransformer transformer, bool throwOnError) {
            if (!Personalization.IsModifiable) {
                if (throwOnError) {
                    // Will throw appropriate exception
                    Personalization.EnsureEnabled(/* ensureModifiable */ true);
                }
                else {
                    return false;
                }
            }

            if (provider == null) {
                throw new ArgumentNullException("provider");
            }
            if (!Controls.Contains(provider)) {
                throw new ArgumentException(SR.GetString(SR.UnknownWebPart), "provider");
            }

            if (consumer == null) {
                throw new ArgumentNullException("consumer");
            }
            if (!Controls.Contains(consumer)) {
                throw new ArgumentException(SR.GetString(SR.UnknownWebPart), "consumer");
            }

            if (providerConnectionPoint == null) {
                throw new ArgumentNullException("providerConnectionPoint");
            }
            if (consumerConnectionPoint == null) {
                throw new ArgumentNullException("consumerConnectionPoint");
            }

            Control providerControl = provider.ToControl();
            Control consumerControl = consumer.ToControl();

            if (providerConnectionPoint.ControlType != providerControl.GetType()) {
                throw new ArgumentException(SR.GetString(SR.WebPartManager_InvalidConnectionPoint), "providerConnectionPoint");
            }
            if (consumerConnectionPoint.ControlType != consumerControl.GetType()) {
                throw new ArgumentException(SR.GetString(SR.WebPartManager_InvalidConnectionPoint), "consumerConnectionPoint");
            }

            if (provider == consumer) {
                if (throwOnError) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartManager_CantConnectToSelf));
                }
                else {
                    return false;
                }
            }

            if (provider.IsClosed) {
                if (throwOnError) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartManager_CantConnectClosed, provider.ID));
                }
                else {
                    return false;
                }
            }

            if (consumer.IsClosed) {
                if (throwOnError) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartManager_CantConnectClosed, consumer.ID));
                }
                else {
                    return false;
                }
            }

            if (!providerConnectionPoint.GetEnabled(providerControl)) {
                if (throwOnError) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_DisabledConnectionPoint, providerConnectionPoint.ID, provider.ID));
                }
                else {
                    return false;
                }
            }

            if (!consumerConnectionPoint.GetEnabled(consumerControl)) {
                if (throwOnError) {
                    throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_DisabledConnectionPoint, consumerConnectionPoint.ID, consumer.ID));
                }
                else {
                    return false;
                }
            }

            // Check AllowsMultipleConnections on each ConnectionPoint
            if (!providerConnectionPoint.AllowsMultipleConnections) {
                foreach (WebPartConnection c in Connections) {
                    if (c.Provider == provider && c.ProviderConnectionPoint == providerConnectionPoint) {
                        if (throwOnError) {
                            throw new InvalidOperationException(SR.GetString(SR.WebPartConnection_Duplicate, providerConnectionPoint.ID, provider.ID));
                        }
                        else {
                            return false;
                        }
                    }
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:WebPartManager.cs


注:本文中的System.Web.UI.WebControls.WebParts.WebPart.ToControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。