New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Modal Popup

  • Demo Configurator

The Modal Popup feature of RadWindow creates a semi-transparend background behind the popup that hides the rest of the page so that the user cannot interact with the page until the modal dialog is closed.

The main features our ASP.NET modal window has are:

  • the modal background resizes with the browser
  • the modal dialog is centered by default
  • the CenterIfModal property can make it respect the Top and Left properties with regard to an OffsetElement, if one is set
  • the modality can also be toggled through the client-side API of the control during runtime, not only with the server Modal property
  • focusable controls on the main page cannot be tabbed into when a modal dialog is opened - their tabIndex is set to -1 and restored when the dialog is closed
  • the predefined dialogs (RadAlert, RadConfirm and RadPrompt) are always modal to mimic the behaviour of the original browser dialog boxes
  • DefaultVB.aspx
  • DefaultVB.aspx.vb
  • scripts.js
  • styles.css
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="DefaultVB.aspx.vb" Inherits="Telerik.Web.Examples.Window.ModalPopup.DefaultVB" %>

<!DOCTYPE html>
<html xmlns=''>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <link href="styles.css" rel="stylesheet" type="text/css" />
    <script src="scripts.js" type="text/javascript"></script>
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
            <telerik:AjaxSetting AjaxControlID="rbSubmitChanges">
                    <telerik:AjaxUpdatedControl ControlID="modalPopup" />
                    <telerik:AjaxUpdatedControl ControlID="loadingPanelWrapper" LoadingPanelID="ralpConfiguration" />
    <telerik:RadFormDecorator runat="server" ID="RadFormDecorator1" DecoratedControls="Textarea" />
    <div class="demo-container size-custom">
        <textarea tabindex="1" cols="35" rows="5">You cannot type or tab into this text area while the RadWindow is modal even though its tabIndex is set to 1.</textarea>
    <telerik:RadWindow RenderMode="Lightweight" ID="modalPopup" runat="server" Width="360px" Height="365px" Modal="true" OffsetElementID="main" OnClientShow="setCustomPosition" Style="z-index: 100001;">
            <div style="padding: 10px; text-align: center;">
                <telerik:RadButton RenderMode="Lightweight" ID="rbToggleModality" Text="Toggle modality" OnClientClicked="togglePopupModality"
                    AutoPostBack="false" runat="server" Height="65px" />
            <p style="text-align: center;">
                RadWindow is designed with keyboard support in mind - try tabbing
                    before and after removing the modal background. While the popup is modal
                    you cannot focus the text area, once the modality is removed the text area will
                    be the first thing to receive focus because it has tabIndex=1.
    <telerik:RadCodeBlock runat="server" ID="rdbScripts">
        <script type="text/javascript">
            $modalWindowDemo.modalWindowID = "<%=modalPopup.ClientID %>";
    <telerik:RadAjaxLoadingPanel runat="server" ID="ralpConfiguration"></telerik:RadAjaxLoadingPanel>
    <asp:Panel runat="server" ID="loadingPanelWrapper">
        <qsf:ConfiguratorPanel runat="server" ID="rwConfigurationPanel">
                    <qsf:ConfiguratorColumn runat="server">
                        <ul class="fb-group">
                                <asp:CheckBox ID="chkBoxIsModal" Text="RadWindow is modal" Checked="true" runat="server" />
                                <asp:CheckBox ID="chkBoxCenterIfModal" Text="RadWindow will center if it is modal" Checked="true" runat="server" />
                                <qsf:NumericTextBox runat="server" ID="rntbLeft" Label="Left " Size="Narrow" Value="50" MinValue="-2000" MaxValue="2000">
                                    <NumberFormat GroupSeparator="" DecimalDigits="0" />
                                <qsf:NumericTextBox runat="server" ID="rntbTop" Label="Top" Value="50" Size="Narrow" MinValue="-2000" MaxValue="2000">
                                    <NumberFormat GroupSeparator="" DecimalDigits="0" />
                                <qsf:Button ID="rbSubmitChanges" Text="Apply changes" AutoPostBack="true" runat="server" />
                                <qsf:Button ID="rbShowDialog" Text="Show dialog" runat="server" />

Support & Learning Resources

Find Assistance