To Examples
calendar1.aspx Source Code
<!-- calendar1.aspx Example Use a Calendar Web control to select a single date Then format and display this date --> <%@ Page Language="C#" %> <script runat=server> public void btnShowFormattedDate_Click(object sender, EventArgs e) { string d = ; switch (ddlFormat.SelectedItem.Text) { case ToLongDateString: d = calendar1.SelectedDate.ToLongDateString( ); break; case ToShortDateString: d = calendar1.SelectedDate.ToShortDateString( ); break; case ToString: d = calendar1.SelectedDate.ToString( ); break; } litDate.Text = Selected Formatted Date:<br /> + d; } </script> <html> <head> <title>calendar1.aspx Example</title> <link rel=stylesheet type=text/css href=examples.css /> </head> <body> <h2>calendar1.aspx Example</h2> <h3>Select a date and a format, then press the submit button.</h3> <form id=frmCalendar runat=server> <p> <asp:Calendar ID=calendar1 runat=server /> </p> <p> <asp:DropDownList ID=ddlFormat runat=server AutoPostBack=false Font-Bold=True Font-Names=Verdana, Arial Font-Size=X-Small> <asp:ListItem>ToLongDateString</asp:ListItem> <asp:ListItem>ToShortDateString</asp:ListItem> <asp:ListItem>ToString</asp:ListItem> </asp:DropDownList> </p> <p> <asp:Button ID=btnShowFormattedDate Text=Show Formatted Date runat=server OnClick=btnShowFormattedDate_Click /> </p> <p> <asp:Literal ID=litDate Text= runat=server /> </p> </form> </body> </html>