Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Window / Client-side Events

This demo contains 1 or more dialog pages. To view them, hover over the dropdown button () in the Example Source Code & Description section
Event console
Clear log Event log:

  • Client-Side Events


    New: The RadWindow exposes now two more client events - OnClientBeforeShow and OnClientAutoSizeEnd

    RadWindow provides the following client-side events:
    • OnClientBeforeShow - fires just before the RadWindow is shown. You can cancel the show of the RadWindow there
    • OnClientShow - fires after RadWindow is shown
    • OnClientActivate - fires when RadWindow becomes the active window
    • OnClientPageLoad - fires when the page in RadWindow completesloading
    • OnClientBeforeClose - fires just before the RadWindow is closed. You can cancel the closing of the RadWindow there.
    • OnClientClose - fires after RadWindow is being closed
    • OnClientDragStart - fires when the user starts dragging a RadWindow object
    • OnClientDragEnd - fires after RadWindow is being dropped on the page
    • OnClientResize - fires when a RadWindow is being resized
    • OnClientResizeStart - called when the user starts resizing the window.
    • OnClientResizeEnd - called after a resize operation ends.
    • OnClientAutoSizeEnd - fires when a RadWindow's autosize has finished
    • OnClientCommand - fires when the commands Pin, Reload, Minimize and Maximize are executed (when the user presses a titlebar button).
    The properties expect the name of a clientside function to be called. When invoked, two arguments are supplied to the function - the sender[the RadWindow itself], and an events argument.
    When using the close() method to close a RadWindow you can provide an argument to it and it can be extracted through the arguments of the OnClientClose event by using their get_argument method.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.Web.Examples.Window.ClientSideEvents.DefaultCS" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:headtag id="Headtag1" runat="server" />
        <telerik:radcodeblock id="RadCodeBlock2" runat="server">
            <style type="text/css">
                .expandImage
                {
                    display: inline-block;
                    background-image: url('<%= Page.ResolveUrl("~/Common/styles09/sprite09.gif")%>');
                    background-position: -596px -1191px;
                    background-repeat: no-repeat;
                    width: 15px;
                    height: 15px;
                }
                * html .expandImage
                {
                    background-position: -596px -1194px;
                }
                * + html .expandImage
                {
                    background-position: -596px -1194px;
                }
            </style>
        </telerik:radcodeblock>
    </head>
    <body class="BODY" onload="$get('Button1').disabled = true;">
        <form id="Form1" runat="server">
        <qsf:header id="Header1" runat="server" navigationlanguage="c#" />
        <qsf:informationbox id="InformationBox1" runat="server">
            <span style="font-size: 12px;">This demo contains 1 or more dialog pages.
                To view them, hover over the dropdown button (<span class="expandImage"></span>)
                in the <em>Example Source Code &amp; Description</em> section</span>
        </qsf:informationbox>
        <telerik:radcodeblock id="RadCodeBlock1" runat="server">
            <script type="text/javascript">    
               //<![CDATA[

                /**********************************************************
                Window Events
                **********************************************************/
                function OnClientCommand(sender, eventArgs)
                {
                    logEvent("<strong>OnClientCommand</strong>: Command is " + eventArgs.get_commandName());
                }


                function OnClientResizeEnd(sender, eventArgs)
                {
                    logEvent("<strong>OnClientResizeEnd</strong>: RadWindow is resize ended");
                }

                function OnClientResizeStart(sender, eventArgs)
                {
                    logEvent("<strong>OnClientResizeEnd</strong>: RadWindow is resize started");
                }

                function OnClientDragStart(sender, eventArgs)
                {
                    logEvent("<strong>OnClientDragStart</strong>: RadWindow drag started");
                }

                function OnClientDragEnd(sender, eventArgs)
                {
                    logEvent("<strong>OnClientDragEnd</strong>: RadWindow drag ended");
                }

                function OnClientPageLoad(sender, eventArgs)
                {
                    logEvent("<strong>OnClientPageLoad</strong>: RadWindow completed loading the page");
                }

                function OnClientActivate(sender, eventArgs)
                {
                    //LogEvent("<strong>OnClientActivate</strong>: RadWindow is activated.");
                }

                function OnClientBeforeClose(sender, eventArgs)
                {
                    logEvent("<strong>OnClientBeforeClose</strong>: RadWindow is closing.");
                }

                function OnClientclose(sender, eventArgs)
                {
                    $get("Button1").disabled = false;
                    var arg = eventArgs.get_argument();
                    if (arg)
                    {
                        radalert("A custom argument was passed. Its value is: " + arg);
                        logEvent("<strong>OnClientClose</strong>: The RadWindow is closed with an argument. The provided argument is: " + arg);
                    }
                    else
                    {
                        logEvent("<strong>OnClientClose</strong>: RadWindow is closed");
                    }
                }

                function OnClientshow(sender, eventArgs)
                {
                    $get("Button1").disabled = true;
                    logEvent("<strong>OnClientShow</strong>: RadWindow is shown.");
                }

                function OnClientBeforeShow(sender, eventArgs)
                {
                    logEvent("<strong>OnClientBeforeShow</strong>: RadWindow is showing.");
                }

                function OnClientAutoSizeEnd(sender, eventArgs)
                {
                    logEvent("<strong>OnClientAutoSizeEnd</strong>: RadWindow is autosized.");
                }

                function OpenWnd()
                {
                    radopen(null, "RadWindow1");
                }
                //]]>
            </script>
        </telerik:radcodeblock>
        <telerik:radscriptmanager id="RadScriptManager1" runat="server">
        </telerik:radscriptmanager>
        <telerik:radformdecorator id="RadFormDecorator" runat="server" />
        <table class="table">
            <tr>
                <td>
                    <strong>Event console</strong>
                </td>
                <td>
                    <asp:Button ID="Button1" runat="server" OnClientClick="OpenWnd();return false;" Text="Open RadWindow" />
                </td>
            </tr>
            <tr>
                <td style="text-align: left">
                    <qsf:eventlogconsole id="EventLogConsole1" runat="server" allowclear="true" width="400px"
                        height="300px" />
                </td>
                <td>
                    <div id="RestrictionZone" class="module" style="margin-top: 4px; height: 300px; width: 400px;">
                        <telerik:radwindowmanager id="RadWindowManager1" runat="server" enableshadow="true">
                            <Windows>
                                <telerik:RadWindow runat="server" ID="RadWindow1" ReloadOnShow="true" RestrictionZoneID="RestrictionZone"
                                    Height="300px" Width="400px" NavigateUrl="Dialog.aspx" VisibleOnPageLoad="true" AutoSize="true" Animation="Fade"
                                    OpenerElementID="link1" OnClientCommand="OnClientCommand" ShowContentDuringLoad="false"
                                    OnClientResizeStart="OnClientResizeStart" OnClientResizeEnd="OnClientResizeEnd"
                                    OnClientDragStart="OnClientDragStart" OnClientDragEnd="OnClientDragEnd" OnClientActivate="OnClientActivate"
                                    OnClientPageLoad="OnClientPageLoad" OnClientBeforeClose="OnClientBeforeClose"
                                    OnClientClose="OnClientclose" OnClientShow="OnClientshow" OnClientBeforeShow="OnClientBeforeShow" OnClientAutoSizeEnd="OnClientAutoSizeEnd" />
                            </Windows>
                        </telerik:radwindowmanager>
                    </div>
                </td>
            </tr>
        </table>
        <qsf:footer runat="server" id="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451