|
Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
|
Tradução
Original
|
Classe WebPartTransformer
System.Web.UI.WebControls.WebParts.WebPartTransformer
System.Web.UI.WebControls.WebParts.RowToFieldTransformer
System.Web.UI.WebControls.WebParts.RowToParametersTransformer
Namespace: System.Web.UI.WebControls.WebParts
Assembly: System.Web (em System.Web.dll)
O tipo WebPartTransformer expõe os membros a seguir.
| Nome | Descrição | |
|---|---|---|
![]() | 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 (Função Server Core sem suporte), Windows Server 2008 R2 (Função Server Core com suporte com o SP1 ou posterior, Itanium sem suporte)
O .NET Framework não oferece suporte a todas as versões de cada plataforma. Para obter uma lista das versões com suporte, consulte .Requisitos de sistema do NET Framework.
