CatalogZoneBase.SelectedPartLinkStyle 属性

定义

获取一个对象,该对象包含区域中当前所选 CatalogPart 控件的样式特性。

public:
 property System::Web::UI::WebControls::Style ^ SelectedPartLinkStyle { System::Web::UI::WebControls::Style ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.Style SelectedPartLinkStyle { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.SelectedPartLinkStyle : System.Web.UI.WebControls.Style
Public ReadOnly Property SelectedPartLinkStyle As Style

属性值

Style,包含当前所选控件的样式特性。

属性

示例

下面的代码示例演示如何以声明方式和编程方式使用 SelectedPartLinkStyle 属性。 有关运行该示例所需的完整代码,请参阅类概述的 CatalogZoneBase “示例”部分。

请注意,代码示例的第一部分声明两 <asp:catalogzone> 个元素,第一部分声明 属性的值 SelectedPartLinkStyle

<asp:CatalogZone ID="CatalogZone1" runat="server"
  EmptyZoneText="No controls are in the zone."
  HeaderText="My Web Parts Catalog"
  InstructionText="Add Web Parts controls to the zone."
  PartLinkStyle-Font-Italic="true"
  SelectedPartLinkStyle-Font-Bold="true"
  SelectTargetZoneText="Select zone"
  AddVerb-Text="Add Control"
  CloseVerb-Description="Close and return to browse mode." 
  SelectedCatalogPartID="Currently Selected CatalogPart ID.">
  <ZoneTemplate>
    <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
      runat="server">
      <WebPartsTemplate>
        <aspSample:TextDisplayWebPart 
          runat="server"   
          id="textwebpart" 
          title = "Text Content WebPart" 
          ExportMode="All"/>  
        <asp:Calendar id="calendar1" runat="server" 
          Title="My Calendar" />               
      </WebPartsTemplate>
    </asp:DeclarativeCatalogPart> 
    <asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
    <asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server" /> 
  </ZoneTemplate>
</asp:CatalogZone>
<hr />
<asp:CatalogZone ID="CatalogZone2" runat="server"
  BorderWidth="2"
  HeaderText="My Empty CatalogZone"
  EmptyZoneText="No controls are in the zone." />
<asp:CatalogZone ID="CatalogZone1" runat="server"
  EmptyZoneText="No controls are in the zone."
  HeaderText="My Web Parts Catalog"
  InstructionText="Add Web Parts controls to the zone."
  PartLinkStyle-Font-Italic="true"
  SelectedPartLinkStyle-Font-Bold="true"
  SelectTargetZoneText="Select zone"
  AddVerb-Text="Add Control"
  CloseVerb-Description="Close and return to browse mode." 
  SelectedCatalogPartID="Currently Selected CatalogPart ID.">
  <ZoneTemplate>
    <asp:DeclarativeCatalogPart ID="DeclarativeCatalogPart1" 
      runat="server">
      <WebPartsTemplate>
        <aspSample:TextDisplayWebPart 
          runat="server"   
          id="textwebpart" 
          title = "Text Content WebPart" 
          ExportMode="All"/>  
        <asp:Calendar id="calendar1" runat="server" 
          Title="My Calendar" />               
      </WebPartsTemplate>
    </asp:DeclarativeCatalogPart> 
    <asp:PageCatalogPart ID="PageCatalogPart1" runat="server" />
    <asp:ImportCatalogPart ID="ImportCatalogPart1" runat="server" /> 
  </ZoneTemplate>
</asp:CatalogZone>
<hr />
<asp:CatalogZone ID="CatalogZone2" runat="server"
  BorderWidth="2"
  HeaderText="My Empty CatalogZone"
  EmptyZoneText="No controls are in the zone." />

在代码示例的第二部分中,所选 CatalogPart 控件的文本颜色设置为不同的值。

protected void Button5_Click(object sender, EventArgs e)
{
  CatalogZone1.PartLinkStyle.ForeColor = System.Drawing.Color.Red;
  CatalogZone1.SelectedPartLinkStyle.ForeColor = 
    System.Drawing.Color.Blue;
}
Protected Sub Button5_Click(ByVal sender As Object, _
  ByVal e As EventArgs)
  CatalogZone1.PartLinkStyle.ForeColor = _
    System.Drawing.Color.Red
  CatalogZone1.SelectedPartLinkStyle.ForeColor = _
    System.Drawing.Color.Blue
End Sub

在浏览器中加载页面时,可以从下拉列表中选择“ 目录 ”以切换到目录显示模式。 当目录可见时,单击列出的 CatalogPart 控件之一的链接,并注意所选控件的样式属性。 可以单击“ 更改部件链接样式 ”按钮更改所选控件的文本颜色。 还可以单击未选择的控件的链接,以查看选择控件时样式属性如何更改。

注解

在区域中 CatalogZoneBase ,将显示每种类型的 CatalogPart 控件的链接: PageCatalogPartDeclarativeCatalogPartImportCatalogPart。 当用户单击其中一个链接时,相应的 CatalogPart 控件将成为所选控件,并且该选定控件包含的子控件将变为可见。

Style属性SelectedPartLinkStyle引用的对象包含当前所选控件的链接CatalogPart的样式属性。 尽管 属性引用的对象是只读的,但你仍然可以使用它来设置所选 CatalogPart 控件的基础样式特征。

适用于

另请参阅