DayPilot Knowledge Base

AJAX Calendar/Scheduling Controls
DayPilot Pro (AJAX Calendar Control)
» DayPilot ASP.NET Calendar
DayPilot Pro (AJAX Monthly Calendar Control)
» DayPilot ASP.NET Monthly Calendar
DayPilot Pro (AJAX Scheduler Control)
» DayPilot ASP.NET Scheduler
DayPilot » Knowledge Base » Events show HTML source during image export (PNG)

Events show HTML source during image export (PNG)

Last revision: Mar 2, 2010

Problem

The exported image (PNG, GIF, JPG) shows HTML source instead of formatted text. This can happen at the following places:

Explanation

HTML rendering is not supported during image export.

Workaround

Use the Before*Render events to supply plain text instead of the HTML. The export can be detected by checking IsExport property.

Example 1 (Calendar events)

    protected void DayPilotCalendar1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
    {
        if (DayPilotCalendar1.IsExport) {
          e.InnerHTML = e.Text;
        }
        else {
          e.InnerHTML = String.Format("<span style='color:green'>{0}</span>", e.Text);
        }
    }

Example 2 (Scheduler upper-left corner)

    protected void DayPilotScheduler1_BeforeResHeaderRender(object sender, DayPilot.Web.Ui.Events.BeforeHeaderRenderEventArgs e)
    {
        if (e.IsCorner)
        {
            if (DayPilotScheduler1.IsExport)
            {
                e.InnerHTML = DayPilotScheduler1.StartDate.Year.ToString();
            }
            else
            {
                e.InnerHTML = String.Format("<div style="padding: 5px; font-weight: bold; font-size: 22px; text-align: center;">{0}</div>", DayPilotScheduler1.StartDate.Year);
            }
        }
    }

Controls: Calendar, Month, Scheduler

Related

How to customize 'Week N' string in the Scheduler header
How to use Scheduler with 100% height
How to add a header to the exported calendar image (PNG)
How to add image to an event in DayPilot Month