Skip to main content
A newer version of this page is available. .
Tab

CalendarDayCellInitializeEventArgs.NavigateUrl Property

Gets or sets a URL that defines the navigation location for the date hyperlink.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.2.dll

Declaration

public string NavigateUrl { get; set; }

Property Value

Type Description
String

A String value that is a URL to where the client web browser will navigate when the date’s text is clicked.

Remarks

If the NavigateUrl property is assigned, the date’s display text (which can be accessed via the CalendarDayCellInitializeEventArgs.DisplayText property) serves as a hyperlink. Use the NavigateUrl property to specify a URL to which the client web browser navigates whenever the date’s link is clicked. You can target the specified URL’s contents by using the CalendarDayCellInitializeEventArgs.NavigateUrlTarget property.

The NavigateUrl property is not in effect if the rendered day cell’s content is customized using the CalendarDayCellCreatedEventArgs.Controls property.

Example

The code sample below demonstrates how you can handle the ASPxCalendar.DayCellInitialize and ASPxCalendar.DayCellPrepared events to conditionally change the manner with which you render calendar days within a single month. The image below shows the result.

Calendar_Events

using System.Xml;
using DevExpress.Web.ASPxEditors;
using System.Drawing;

public partial class ASPxCalendar_DayRender : Page {
    XmlDocument xml;

    protected void Page_Load(object sender, EventArgs e) {
        this.xml = new XmlDocument();
        this.xml.Load(MapPath("~/App_Data/CalendarNotes.xml"));
    }

    protected void ASPxCalendar_DayCellInitialize(object sender, CalendarDayCellInitializeEventArgs e) {
        if(GetNoteNodes(e.Date).Count > 0) {
            e.IsWeekend = false;
            e.NavigateUrl = string.Format("javascript:ShowNotes('{0}')", GetDateString(e.Date));
        } else {
            e.IsWeekend = true;
        }        
    }

    protected void ASPxCalendar_DayCellPrepared(object sender, CalendarDayCellPreparedEventArgs e) {
        if(GetNoteNodes(e.Date).Count > 0) {
            e.TextControl.ForeColor = Color.Black;
            e.TextControl.Font.Bold = true;
        }
    }

    string GetDateString(DateTime date) {
        return date.ToString("M/d/yyyy", CultureInfo.InvariantCulture);
    }

    XmlNodeList GetNoteNodes(DateTime date) {
        return GetNoteNodes(GetDateString(date));
    }

    XmlNodeList GetNoteNodes(string dateString) {
        return this.xml.SelectNodes(string.Format("//Notes/Note[@Date='{0}']", dateString));
    }

    ...

}
See Also