Saturday, 29 June 2013

Add Events in the Calendar or How To Create Calender Event like Birthday in Asp.Net


Description:-


              Here we add the Birthaday, Anniversary and Meetings in the relevant dates of the calendar.
  in this example we explain that how to create Fancy or Beautiful Calender and set Event in Calender like Birthday Event,Marriage Event same like as Facebook or Google etc...

you can easily create your Event in Calender and it will Automatically Display this event on the Date that you are set it when you enter the event in Calender.

you can easily Add the Event in Calender and easily view the List of Event by choosing Date.


For Ex:- 
                Look at this the above example when we click on 22 june 2013 date then it will display all Event of 22 june in gridview Format.


Fancy Image Slideshow of Image in Jquery Beautiful Slideshow in Jquery 

Awesome Login Popup in Jquery Signup and Login Popup in Jquery  



 calenderevent.aspx:-


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="calenderevent.aspx.cs" Inherits="calenderevent" %>
<%@ Register TagPrefix="ECalendar" Namespace="ExtendedControls" Assembly="EventCalendar" %>

<!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 id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     &nbsp;<asp:GridView ID="gvSelectedDateEvents" runat="server" Width="100%">
        </asp:GridView>
        <ECalendar:EventCalendar ID="Calendar1" runat="server" BackColor="#FFFFCC" BorderColor="Silver"
            BorderWidth="1px" Font-Names="Verdana"
            Font-Size="9pt" ForeColor="Black" Height="500px"
            Width="800px" FirstDayOfWeek="Monday" NextMonthText="Next &gt;" PrevMonthText="&lt; Prev" SelectionMode="DayWeekMonth" ShowGridLines="True" NextPrevFormat="ShortMonth"
            ShowDescriptionAsToolTip="True" BorderStyle="Solid" EventDateColumnName="" EventDescriptionColumnName="" EventHeaderColumnName="" OnSelectionChanged="Calendar1_SelectionChanged" DayHeaderStyle-BackColor="#FF99FF" DayHeaderStyle-BorderColor="#CC99FF" DayHeaderStyle-Font-Bold="True" DayStyle-ForeColor="#66FF33" Font-Bold="True" SelectedDayStyle-BackColor="#CCFFFF" SelectedDayStyle-BorderColor="Black" SelectedDayStyle-Font-Bold="True" SelectedDayStyle-ForeColor="Aqua" TitleStyle-Font-Bold="True" TitleStyle-ForeColor="#CC3300" TodayDayStyle-BackColor="Yellow" NextPrevStyle-Font-Bold="True" NextPrevStyle-BackColor="#9900FF" DayHeaderStyle-ForeColor="#339966">
            <SelectedDayStyle BackColor="#333399" ForeColor="White" />
            <TodayDayStyle BackColor="#CCCCCC" />
            <SelectorStyle BorderColor="#404040" BorderStyle="Solid" />
            <DayStyle HorizontalAlign="Left" VerticalAlign="Top" Wrap="True" />
            <OtherMonthDayStyle ForeColor="#999999" />
            <NextPrevStyle Font-Size="8pt" ForeColor="#333333" Font-Bold="True" VerticalAlign="Bottom" />
            <DayHeaderStyle BorderWidth="1px" Font-Bold="True" Font-Size="8pt" />
            <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True"
                Font-Size="12pt" ForeColor="#333399" HorizontalAlign="Center" VerticalAlign="Middle" />
        
            <TodayDayStyle />
        
            <SelectorStyle BorderColor="#404040" BorderStyle="Solid" />
            <DayStyle HorizontalAlign="Left" VerticalAlign="Top" Wrap="True" />
            <DayHeaderStyle BorderWidth="1px" />
            <TitleStyle HorizontalAlign="Center" VerticalAlign="Middle" />
        </ECalendar:EventCalendar>
    </div>
    </form>
</body>
</html>



 calenderevent.aspx.cs:-


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class calenderevent : System.Web.UI.Page
{
    private DataTable GetEvents()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("EventDate", Type.GetType("System.DateTime"));
        dt.Columns.Add("EventHeader", Type.GetType("System.String"));
        dt.Columns.Add("EventDescription", Type.GetType("System.String"));

        DataRow dr;

        // Last Week's Events
        dr = dt.NewRow();
        dr["EventDate"] = DateTime.Now.AddDays(-7);
        dr["EventHeader"] = "My Last Week's Event 1";
        dr["EventDescription"] = "My Last Week's Event 1 Description";
        dt.Rows.Add(dr);

        // Yesterday's Events
        dr = dt.NewRow();
        dr["EventDate"] = DateTime.Now.AddDays(-1);
        dr["EventHeader"] = "My Yesterday's Event 1";
        dr["EventDescription"] = "My Yesterday's Event 1 Description";
        dt.Rows.Add(dr);

        // Todays Events
        dr = dt.NewRow();
        dr["EventDate"] = DateTime.Now;
        dr["EventHeader"] = "My Todays Event 1";
        dr["EventDescription"] = "My Todays Event 1 Description";
        dt.Rows.Add(dr);

        dr = dt.NewRow();
        dr["EventDate"] = DateTime.Now;
        dr["EventHeader"] = "My Todays Event 2";
        dr["EventDescription"] = "My Todays Event 2 Description";
        dt.Rows.Add(dr);

        // Tomorrow's Events
        dr = dt.NewRow();
        dr["EventDate"] = DateTime.Now.AddDays(1);
        dr["EventHeader"] = "My Tomorrow's Event 1";
        dr["EventDescription"] = "My Tomorrow's Event 1 Description";
        dt.Rows.Add(dr);

        return dt;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        Calendar1.EventDateColumnName = "EventDate";
        Calendar1.EventDescriptionColumnName = "EventDescription";
        Calendar1.EventHeaderColumnName = "EventHeader";

        Calendar1.EventSource = GetEvents();
    }

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        SelectedDatesCollection theDates = Calendar1.SelectedDates;
        DataTable dtEvents = Calendar1.EventSource;

        DataTable dtSelectedDateEvents = dtEvents.Clone();
        DataRow dr;

        foreach (DataRow drEvent in dtEvents.Rows)
            foreach (DateTime selectedDate in theDates)
                if ((Convert.ToDateTime(drEvent[Calendar1.EventDateColumnName])).ToShortDateString() == selectedDate.ToShortDateString())
                {
                    dr = dtSelectedDateEvents.NewRow();
                    dr[Calendar1.EventDateColumnName] = drEvent[Calendar1.EventDateColumnName];
                    dr[Calendar1.EventHeaderColumnName] = drEvent[Calendar1.EventHeaderColumnName];
                    dr[Calendar1.EventDescriptionColumnName] = drEvent[Calendar1.EventDescriptionColumnName];
                    dtSelectedDateEvents.Rows.Add(dr);
                }

        gvSelectedDateEvents.DataSource = dtSelectedDateEvents;
        gvSelectedDateEvents.DataBind();

    }
}



This entry was posted in :

0 comments:

Post a Comment