Calendar.CaptionAlign 属性

定义

获取或设置呈现为日历标题的文本的对齐方式。

public virtual System.Web.UI.WebControls.TableCaptionAlign CaptionAlign { get; set; }

属性值

一个 TableCaptionAlign 值,指示标题的对齐方式。

例外

指定的值不是 TableCaptionAlign 值之一。

示例

下面的代码示例演示如何使用 CaptionAlign 属性对齐控件的 Calendar 标题。

<%@ Page Language="C#" AutoEventWireup="True" %>

<!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 runat="server">
    <title> Calendar Caption and Caption Align Example </title>
</head>
<body>

   <form id="form1" runat="server">
  
      <h3> Calendar Caption and Caption Align Example </h3>

      <br /><br /> 
  
      <asp:Calendar id="Calendar1"
           ShowGridLines="True" 
           ShowTitle="True"
            Caption="This calendar is used to demonstrate a calendar caption. It also shows
            how the caption can be aligned to the calendar, in this case to the right edge of
            the calendar."
            CaptionAlign="right"  
           runat="server"/>

      <br /><br />

   </form>

</body>
</html>

注解

此属性确定标题相对于 Calendar 控件的显示位置。 默认值 NotSet为 ,它允许浏览器确定标题的对齐位置。 下表说明了 值与标题外观之间的关系 TableCaptionAlign

TableCaptionAlign 外观
Bottom 标题显示在日历底部,文本居中。
Left 标题显示在日历顶部,文本左对齐。
NotSet 标题对齐方式未设置,由浏览器确定。
Right 标题显示在日历顶部,文本右对齐。
Top 标题显示在日历顶部,文本居中。

适用于

产品 版本
.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

另请参阅