Aug 7, 2011

How to use Calendar with Literal Controls in

(i) .ASPX File Content
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head runat="server">
    <title>Calendar with Literal Controls Page</title>
    <form id="form1" runat="server">
    <asp:Calendar Runat="server" ID="Cal" BorderStyle="Solid" BackColor="White" Width="162px" ForeColor="Black" 
     CellSpacing="1" Height="113px" Font-Size="9pt" Font-Names="Verdana" 
     BorderColor="Black" PrevMonthText="Prev" NextMonthText="Next" ShowGridLines="True"
     TitleFormat="Month" SelectionMode="DayWeekMonth" OnSelectionChanged="Cal_SelectionChanged" />
     <asp:Literal ID="Literal1" Runat="server" />
(ii) .ASPX.CS File Content
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
    protected void Cal_SelectionChanged(object sender, EventArgs e)
            foreach (DateTime date in Cal.SelectedDates)
                Literal1.Text = " Selected Date is  :" + date.ToString("d");
        catch (Exception )
(iii) Output

No comments:

Post a Comment