• Apache Software License 2.0


  • Displays HTML or a standalone page
  • Modal - hides the background with a semi-transparent div
  • Draggable modal window
  • Auto-stretching to show all content
  • Support for ASP.NET WebForms, MVC
  • Works well with jQuery (but jQuery is not required)

Displaying the modal dialog

Displaying an URL:

var modal = new DayPilot.Modal();

Displaying HTML:

var modal = new DayPilot.Modal();

Configuring the modal dialog


Whether the height should be increased automatically to avoid scrollbar, until .maxHeight is reached.

Default value: true


If set to false, stretch() will be registered to onload event and fired after PostBack as well.

Default value: false


Modal dialog border style.

Default value: "1px solid black"


Function called when the modal dialog is closed using .close() method. The result is stored in .result.

Default value: null


"Rounded" or "Regular".

Default value: "Rounded"


CSS class of the main div.

Defalt value: null


Whether modal window dragging should be enabled (move it by dragging the border).

Default value: true


Height in pixels. If autoStretch is enabled, this is the minimal height.

Default value: 200


Maximum height in pixels when using autoStretch. If not set, it will be stretched until the bottom space is equal to .top.

Default value: null


Opacity of the background hiding div (0-100).

Default value: 30


Whether the modal should scroll with the page or stay at the same position (fixed).

Default value: true


Y position of the modal dialog in pixels.

Default value: 20


Whether iframe should be used to display the modal dialog content. Only applicable for showHtml(), iframe is forced when displaying a separate page using showUrl().

Default value: true


Width of the modal dialog in pixels.

Default value: 300


z-index of the background hiding div.

Move the dialog by dragging


modal.dragDrop = true; // default

Nested dialogs

It is possible to open another modal dialog from an already open dialog. You need to create the DayPilot.Modal instance on the main page (not inside the modal) and access it using window.parent.


If autoStretch is set to true (default) the window will stretch its height automatically to avoid vertical scrollbar.

You can also call it manually


Closing the modal dialog


Call DayPilot.ModalStatic.close(). If you call it from the modal dialog page, you need to access it using window.parent:



See: How to show a modal dialog in ASP.NET MVC Razor

ASP.NET WebForms

Call Modal.Close() on the page displayed inside the modal dialog (DayPilot.Modal-2.0.cs is required):


Passing result data to the main page

You can pass a custom object to the modal dialog when closing it.

The custom object will be accessible as .result. You can read it in .closed handler. 

On the server side, use a Hashtable to create a more complex object:

Hashtable ht = new Hashtable();
ht["refresh"] = "yes";
ht["message"] = "Event updated.";

Using the modal popup with UpdatePanel

At this moment, Modal.Close() doesn't work if you call it during asynchronous PostBack. You need to add the close button to PostBack triggers:

<asp:UpdatePanel ID="UpdatePanel" runat="server">
    <asp:PostBackTrigger ControlID="ButtonOK" />

You can also update the modal dialog height automatically after the UpdatePanel height changes:

<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function (sender, args) {
  modal.stretch(); });