|
|
Try the online demo:
AJAX-style event creating, moving, resizing, and deleting
Context menu
Day view
Work week view
Week view
Month view
Horizontal/vertical resources view
PostBack/AJAX/JavaScript event handling
Binding to XmlDataSource, SqlDataSource, DataTable, ArrayList
Custom event formatting
UpdatePanel compatibility
Calendar Tutorial: Database & Event Moving (ASP.NET, C#, VB.NET)April 24, 2009 [updated May 5, 2009] This tutorial shows how to use DayPilot Calendar in a web application. It includes both C# and VB.NET version. Download
FeaturesIt is a minimalistic version:
Installation[Optional] You can add the DayPilot controls to the Visual Studio Toolbox: Web Site
Web Form (Page)
Adding the Calendar ControlAdd the following line to Default.aspx, right below <%@ Page ... %> line: <%@ Register Assembly="DayPilot" Namespace="DayPilot.Web.Ui" TagPrefix="DayPilot" %> Copy the following snippet to the page (inside <form> element): C# <daypilot:daypilotcalendar VB.NET <daypilot:daypilotcalendar The following attributes are required by ASP.NET:
The following attributes are required by DayPilot:
We define a few additional attributes:
For C# we also define a EventMove event handler here (in VB.NET it's defined using Handles clause in the Default.aspx.vb):
Adding the FunctionalityThe code behind file (Default.aspx.cs or Default.aspx.vb) must contain two event handlers:
Page_LoadWe will load events from the DB to the Calendar during the initial web page load. C# protected void Page_Load(object sender, EventArgs e) VB.NET Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load DayPilotCalendar1_EventMoveWe will update the DB to actually move an event and send an updated event set back to the client. C# protected void DayPilotCalendar1_EventMove(object sender, DayPilot.Web.Ui.Events.EventMoveEventArgs e) VB.NET Protected Sub DayPilotCalendar1_EventMove(ByVal sender As Object, ByVal e As DayPilot.Web.Ui.Events.EventMoveEventArgs) Handles DayPilotCalendar1.EventMove DatabaseIn this tutorial, we are using SQLite embedded database and SQLite ADO.NET Provider to limit the external dependencies (both the ADO.NET driver and the database engine are in a single file - System.Data.SQLite.DLL - in Bin directory). The database file (daypilot.sqlite) can be found in App_Data directory. The database structure can be examined using SQLite Administrator. The database contains a single table with the following structure: CREATE TABLE event ( Loading eventsC# private DataTable dbGetEvents(DateTime start, int days) VB.NET Private Function dbGetEvents(ByVal start As DateTime, ByVal days As Integer) As DataTable Updating an eventC# private void dbUpdateEvent(string id, DateTime start, DateTime end) VB.NET Private Sub dbUpdateEvent(ByVal id As String, ByVal start As DateTime, ByVal [end] As DateTime)
DayPilot Pro is an advanced DayPilot edition. You can check a thumbnail overview of the most interesting features. There is also an online demo with all the features working (including the AJAX features). If you want to test the design-time support and API you can download a fully functional trial version. And if you like it, you can buy a full version with source code and 12 months of upgrades and support (with a 30-days money back guarantee). DayPilot Lite is a do-it-yourself open-source edition of DayPilot. Although it misses some DayPilot Pro features, there are thousands of developers using it to build calendar, personal scheduling, and resource booking applications. |