Calendar.CaptionAlign Property

 

Gets or sets the alignment of the text that is rendered as a caption for the calendar.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public virtual TableCaptionAlign CaptionAlign { get; set; }

Property Value

Type: System.Web.UI.WebControls.TableCaptionAlign

A TableCaptionAlign value that indicates the alignment of the caption.

Exception Condition
ArgumentOutOfRangeException

The value specified is not one of the TableCaptionAlign values.

This property determines where the caption appears in relation to the Calendar control. The default value is NotSet, which lets the browser determine where to align the caption. The following table explains the relationship between the TableCaptionAlign value and the appearance of the caption.

TableCaptionAlign value

Appearance

Bottom

The caption appears at the bottom of the calendar, with the text centered.

Left

The caption appears at the top of the calendar, with the text left-aligned.

NotSet

The caption alignment is not set and is determined by the browser.

Right

The caption appears at the top of the calendar, with the text right-aligned.

Top

The caption appears at the top of the calendar with the text centered.

The following code example demonstrates how to use the CaptionAlign property to align a caption for a Calendar control.

<%@ 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>

.NET Framework
Available since 2.0
Return to top
Show: