使用英语阅读

通过


WebPart.TitleUrl 属性

定义

获取或设置有关 WebPart 控件补充信息的 URL。

[System.Web.UI.Themeable(false)]
[System.Web.UI.WebControls.WebParts.Personalizable(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared)]
public virtual string TitleUrl { get; set; }

属性值

一个字符串,表示有关 WebPart 控件详细信息的 URL。 默认值为空字符串 ("")。

实现

属性

例外

内部验证系统已确定 URL 可能包含脚本攻击。

示例

下面的代码示例演示如何为自定义 Web 部件控件设置 TitleUrl 属性。 此示例假定使用自定义控件 , TextDisplayWebPart该控件位于类概述的 WebPart “示例”部分。

请注意, <aspSample:TextDisplayWebPart> 元素包含 TitleUrl 具有虚构 URL 的属性。 如果在浏览器中加载页面,则控件的 WebPart 标题现在是指向 属性指向 TitleUrl 的资源的链接。

<%@ page language="C#" %>
<%@ register tagprefix="aspSample" 
             Namespace="Samples.AspNet.CS.Controls" 
             Assembly="TextDisplayWebPartCS"%>

<!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 id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="Form1" runat="server">
      <asp:webpartmanager id="WebPartManager1" runat="server" />
    <asp:webpartzone
      id="WebPartZone1"
      runat="server"
      title="Zone 1"
      PartChromeType="TitleAndBorder">
        <parttitlestyle font-bold="true" ForeColor="#3300cc" />
        <partstyle
          borderwidth="1px"   
          borderstyle="Solid"  
          bordercolor="#81AAF2" />
        <zonetemplate>
          <aspSample:TextDisplayWebPart 
            runat="server"   
            id="textwebpart" 
            title = "Text Content WebPart" 
            TitleUrl="HelpFile.htm"
            />
          </zonetemplate>
    </asp:webpartzone>
  </form>
</body>
</html>

注解

向 属性分配 URL TitleUrl 时,控件的标题将成为有关控件的补充信息的链接。 当页面处于可拖动控件的显示模式(例如设计、编辑或目录模式)时,不会呈现 URL。

无法通过主题或样式表主题设置此属性。 有关详细信息,请参阅 ThemeableAttributeASP.NET 主题和外观

此属性的个性化设置范围设置为 Shared ,并且只能由授权用户修改。 有关详细信息,请参阅 PersonalizableAttributeWeb 部件个性化概述

适用于

产品 版本
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

另请参阅