|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
WebPartTransformer, classe
System.Web.UI.WebControls.WebParts.WebPartTransformer
System.Web.UI.WebControls.WebParts.RowToFieldTransformer
System.Web.UI.WebControls.WebParts.RowToParametersTransformer
Espace de noms : System.Web.UI.WebControls.WebParts
Assembly : System.Web (dans System.Web.dll)
Le type WebPartTransformer expose les membres suivants.
| Nom | Description | |
|---|---|---|
![]() | WebPartTransformer |
| Nom | Description | |
|---|---|---|
![]() | CreateConfigurationControl | |
![]() | Equals(Object) | |
![]() | Finalize | |
![]() | GetHashCode | |
![]() | GetType | |
![]() | LoadConfigurationState | |
![]() | MemberwiseClone | |
![]() | SaveConfigurationState | |
![]() | ToString | |
![]() | Transform |
// An interface that the transformer provides to the consumer. [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public interface IString { void GetStringValue(StringCallback callback); }
// A transformer that transforms a row to a string. [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [WebPartTransformer(typeof(IWebPartRow), typeof(IString))] public class RowToStringTransformer : WebPartTransformer, IString { private IWebPartRow _provider; private StringCallback _callback; private void GetRowData(object rowData) { PropertyDescriptorCollection props = _provider.Schema; if (props != null && props.Count > 0 && rowData != null) { string returnValue = String.Empty; foreach (PropertyDescriptor prop in props) { if (prop != props[0]) { returnValue += ", "; } returnValue += prop.DisplayName + ": " + prop.GetValue(rowData); } _callback(returnValue); } else { _callback(null); } } public override object Transform(object providerData) { _provider = (IWebPartRow)providerData; return this; } void IString.GetStringValue(StringCallback callback) { if (callback == null) { throw new ArgumentNullException("callback"); } if (_provider != null) { _callback = callback; _provider.GetRowData(new RowCallback(GetRowData)); } else { callback(null); } } }
<%@ Page language="c#" trace="false" debug="true" %> <%@ register tagprefix="uc1" tagname="DisplayModeMenuCS" src="~/displaymodemenucs.ascx" %> <%@ Register TagPrefix="wp" NameSpace="Samples.AspNet.CS.Controls" %> <script runat="server"> </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Web Parts Transformer Sample Page</title> </head> <body> <form id="Form1" runat="server"> <asp:webpartmanager id="manager" runat="server"> <staticconnections> <asp:webpartconnection id="conn1" providerid="p1" consumerid="c1"> <wp:rowtostringtransformer /> </asp:webpartconnection> </staticconnections> </asp:webpartmanager> <uc1:displaymodemenucs id="menu1" runat="server" /> <table> <tr valign="top"> <td> <asp:webpartzone id="zone1" headertext="zone1" runat="server"> <zonetemplate> <wp:rowproviderwebpart id="p1" runat="server" /> <wp:stringconsumerwebpart id="c1" runat="server" /> </zonetemplate> </asp:webpartzone> </td> <td> <asp:connectionszone id="connectionszone1" runat="server" /> </td> </tr> </table> </form> </body> </html>
<webParts enableExport="true">
<transformers>
<add name="RowToStringTransformer"
type="Samples.AspNet.VB.Controls.RowToStringTransformer" />
</transformers>
</webParts>
<webParts enableExport="true">
<transformers>
<add name="RowToStringTransformer"
type="Samples.AspNet.CS.Controls.RowToStringTransformer" />
</transformers>
</webParts>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
