[
Advertise | Submit Code | About us | Contact us | Link us
]
Go!
Membership Services
Login
Register

Home
C# General

General

C# Language

Design & Architecture

Algorithms

Database

Security

Active Directory

COM Interop

Remoting
C# Windows Forms

General

Combo and List boxes

Miscellaneous Controls

Button Controls

Edit Controls
Cutting Edge

ASP.NET 2.0

Visual Studio 2005

Windows Longhorn

SQL Server 2005
C# Multimedia and GDI+

General

DirectX

GDI+

Audio
Internet & Web

General

Images and multimedia

Database

Utilities

Security

ASP.NET Controls

Design and Architecture

Webservices
.NET

General

Design & Architecture

Algorithms

Database

Security

Active Directory

COM Interop

Remoting

ADO.NET

XML.NET

Tools

Enterprise

IDE
Visual Basic .NET

VB.NET General

VB.NET Controls
General Reading

.NET Books Review

Product Showcase

Book Chapters

Business Design & Strategy
Community

Discuss

Job Board

Discussion

CodeXchange
DeveloperLand

Advertise

Submit Code

About us

Contact us

Link us
Miscellaneous

Favorite Links

Downloads

Programming Sites

Top Stories
Regular Expressions

E-Mail

Date/Time
Home > Internet & Web > ASP.NET Controls
Calendar of Events in C#
Posted by on Sunday, August 22, 2004 (EST)

A nice little event based calendar that gets events from an SQL database table.


This article has been viewed: 8,630 times
Technology: ASP.NET Controls.

Download the Code [^] - Updated 4/13/2002

This is a C# project for VS.Net.

I needed a web based even calendar and thanks to the new .Net Calendar Control, the rest was easy. What I ended up with was a nice little event based calendar. If you select a date with a scheduled event, a Repeater Control appears below the calendar with event specifics for the day selected. The code was cut from the page on my site (http://dn.yyyz.net/DnYzCalendar.aspx [^])  so there is some extra code that may not be used in this example. A second page located at http://dn.yyyz.net/DnYzCalendarAdmin.aspx [^]  and not covered in this article or currently available for distribution is used to add event times and dates. 

Files Included Description of Included File
CaEvents.htm This Page
Calendar.aspx The .aspx page that holds the calendar and other controls
Calendar.aspx.cs The .aspx.cs page with the calendar code and logic
CaEvents.css Contains a few styles used in the pages
CaEvents.cs A Class based on the database table. Most of the functions are not used in this example but are used in the Set Events page which is not covered in this article.
CaEvents.sql The SQL statement that will create the events table in SQL 2000
Web.Config Make sure that you change the connection string in appSettings

All the calendar formatting and functionality occurs in the yZCalendar.aspx.cs file. The following is a list of functions included in the code behind page and a brief description of each.

Name Description of Functions in Calendar.aspx.cs
SetControls Sets the initial values used in the Year/Month textboxes.
fmtCalendar Adds formatting to the calendar control. I prefer to format in the .aspx.cs file rather than the .aspx file. 
MonthLyEvents Get the events from the database. We get all events for the month, plus 10 days on each side of the month. The calendar control uses a 7x6 grid and it is possible that there could be 8 or 9 days before or after the actual month being presented. We couldn't find a property or method to get the actual starting and ending days so we merely get an additional 10 days of events to insure all dates get presented.
SetDbDates Sets the 1st and last date that we get from the database.
btnJump_Click The event that handles the 'Time Travel' button.
C1DateSelected The event handler when a date is clicked on.
C1MonthRender The event called when the month is changed. We call the SetDbDates function to get the beginning and ending days to use in the database query.
C1DayRender Renders each day of the calendar. This is where any events are added to the calendar. The CaEvents Class contains a 15 character description that is add to the appropriate date. 
BindRepeater Binds the repeater control to list any events scheduled on a selected day.

Top Go to Table of Contents

About DeveloperLand Administrator

Click here if you want to know more about .

Other articles that may interest you

  • Write a Word Add-In – Part 0
  • Write a Word Add-In – Part I
  • Lengthy Operations on Single Thread in .NET Application
  • Learning Draughts
  • Exceptions and Performance
  • Average Rating :

    Discussion Forums
    Got a programming related question? Hopefully someone has the answer... Want to help out other developers? Visit our discussion forums.

    Sponsored by:

    New Articles

  • Exceptions and Performance
    Almost every time exceptions are mentioned in mailing lists and newsgroups, people say they're really expensive.Let's examine that claim, shall we?

  • Creating multilingual websites - Part 1
    Extend the existing globalization capabilities of .NET to create flexible and powerful multilingual web sites. First, create a custom ResourceManager, and then create custom localized-capable server controls to easily deploy multilingual functionality.

  • Parameter passing in C#
    Many people have become fairly confused about how parameters are passed in C#, particularly with regard to reference types. This page should help to clear up some of that confusion

  • Most Popular Articles

  • LDAP, IIS and WinNT Directory Services
    This article explains how to use .NET Directory Services to retrieve and search directory objects, create new directory objects and edit or delete existing directory objects. Describes Active Directory Application Mode (ADAM) and how to use the IIS, WinNT and LDAP directory (ADSI) provider.

  • An in-depth look at WMI and instrumentation, Part II
    WMI stands for Windows Management Instrumentation and, as the name indicates, is about managing your IT infrastructure this article is the second part of a two-part series.

  • An in-depth look at WMI and instrumentation, Part I
    WMI stands for Windows Management Instrumentation and, as the name indicates, is about managing your IT infrastructure this article provides an in-depth look at WMI and MOM 2005

  • New Books

  • Murach's ASP.NET 2.0 Upgrader's Guide: VB Edition
    What’s new and how to use it! That’s what this book delivers if you’re a VB developer who’s interested in upgrading from ASP.NET 1.x to ASP.NET 2.0.

  • C# in easy steps
    Learn to program with Microsoft’s premier programming language. No previous programming knowledge is assumed. With numerous easy-to-follow examples, this title explains the essentials of object-oriented programming with C#.

  • Murach's ASP.NET web programming with VB.NET
    Murach's ASP.NET web programming with VB.NET by Doug Lowe and Anne Prince is a in depth training and reference book for ASP.NET programming using VB.NET. The book builds upon Murach's previous books and covers more advanced concepts for programming ASP.NET pages.

  • Got Code?

    if you have any article , source code , or anything else you'd like to share with this community that you think others might find useful, please submit it here and we will gladly make it available on this site. submit@developerland.com.
    Partners

    All articles are copyrighted by their individual authors unless otherwise specified , everything else Copyright ©2004-2006 DeveloperLand