Calendar.TitleFormat Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur format untuk bagian judul.
public:
property System::Web::UI::WebControls::TitleFormat TitleFormat { System::Web::UI::WebControls::TitleFormat get(); void set(System::Web::UI::WebControls::TitleFormat value); };
[System.ComponentModel.Bindable(true)]
public System.Web.UI.WebControls.TitleFormat TitleFormat { get; set; }
public System.Web.UI.WebControls.TitleFormat TitleFormat { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.TitleFormat : System.Web.UI.WebControls.TitleFormat with get, set
member this.TitleFormat : System.Web.UI.WebControls.TitleFormat with get, set
Public Property TitleFormat As TitleFormat
Nilai Properti
Salah TitleFormat satu nilai. Nilai defaultnya adalah MonthYear.
- Atribut
Pengecualian
Format judul yang ditentukan bukan salah TitleFormat satu nilai.
Contoh
Contoh kode berikut menunjukkan cara menggunakan TitleFormat properti untuk menampilkan bulan dan tahun di bagian judul.
<%@ 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>
<title>Calendar Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Calendar Example</h3>
<asp:Calendar id="calendar1" runat="server"
TitleFormat="MonthYear"/>
</form>
</body>
</html>
<%@ Page Language="VB" 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>
<title>Calendar Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Calendar Example</h3>
<asp:Calendar id="calendar1" runat="server"
TitleFormat="MonthYear"/>
</form>
</body>
</html>
<%@ 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" >
<script runat="server" >
void Selection_Change(Object sender, EventArgs e)
{
// Set the title format.
Calendar1.TitleFormat = (TitleFormat)ModeList.SelectedIndex;
}
</script>
<head runat="server">
<title> Calendar TitleFormat Example </title>
</head>
<body>
<form id="form1" runat="server">
<h3> Calendar TitleFormat Example </h3>
Choose the title format.
<br /><br />
<asp:Calendar id="Calendar1"
ShowGridLines="True"
ShowTitle="True"
runat="server"/>
<br /><br />
<table cellpadding="5">
<tr>
<td>
Format:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="ModeList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem> Month </asp:ListItem>
<asp:ListItem Selected="True"> MonthYear </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</form>
</body>
</html>
<%@ Page Language="VB" 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" >
<script runat="server" >
Sub Selection_Change(sender As Object, e As EventArgs)
' Set the title format.
Calendar1.TitleFormat = CType(ModeList.SelectedIndex, TitleFormat)
End Sub
</script>
<head runat="server">
<title> Calendar TitleFormat Example </title>
</head>
<body>
<form id="form1" runat="server">
<h3> Calendar TitleFormat Example </h3>
Choose the title format.
<br /><br />
<asp:Calendar id="Calendar1"
ShowGridLines="True"
ShowTitle="True"
runat="server"/>
<br /><br />
<table cellpadding="5">
<tr>
<td>
Format:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="ModeList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem> Month </asp:ListItem>
<asp:ListItem Selected="True"> MonthYear </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</form>
</body>
</html>
Keterangan
TitleFormat Gunakan properti untuk menentukan format untuk bagian judul. Properti ini diatur dengan salah TitleFormat satu nilai enumerasi. Anda dapat menentukan apakah judul ditampilkan sebagai bulan atau bulan dan tahun.
Properti ini hanya berlaku jika ShowTitle properti diatur ke true.