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

Ajax / Client-side API


  • You can use the RadAjaxManager control or other control which initiates postbacks to initiate your own AJAX requests explicitly on the client. It gives you the possibility to add AJAX functionality to controls that are not specially designed to make AJAX requests or mark a server control as an initiator of the ajax request using the ajaxRequestWithTarget(controlUniqueId, arguments) method.

    In this example you can see an integration between a flash object and the RadAjaxManager/RadListBox controls. On clicking upon fixed regions an AJAX request is made with an argument whose value is the name of the area. The result is a short description of the selected continent or country:

    // this method is invoked from the flash animation
    function InitiateAsyncRequest(arguments)
    {
        var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
        ajaxManager.ajaxRequest(arguments);
    }

    When choosing countries from the RadListBox, the ajaxRequestWithTarget method is invoked to display a description for the relevant country in the description area below:

    //this method is invoked from the OnClientSelectedIndexChanged event of the RadListBox control
    function RefreshDescription(sender, eventArgs)
    {
       var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
       ajaxManager.ajaxRequestWithTarget("<%= CountriesListBox.UniqueID %>", sender.get_selectedItem().get_text());
    }

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="vb" CodeFile="DefaultVB.aspx.vb" AutoEventWireup="false" Inherits="Telerik.AJAXExamplesVBNET.AJAX.Examples.Manager.ClientSideAPI.DefaultVB" %>

    <%@ Register TagPrefix="telerik" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="telerik" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/DTD/xhtml11.dtd">
    <html xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <telerik:HeadTag ID="Headtag1" runat="server"></telerik:HeadTag>
        <link href="styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body class="BODY">
        <form id="Form1" method="post" runat="server">
            <telerik:Header ID="Header2" runat="server" AccessibilityLevel="AA" NavigationLanguage="VB" ShowSkinChooser="false">
            </telerik:Header>
            <!-- content start -->
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadListBoxPanel" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="CountriesListBox">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Sunset" />
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
                // this method is invoked from the flash animation
                function InitiateAsyncRequest(argument) {
                    var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                    ajaxManager.ajaxRequest(argument);
                    return false;
                }
                function RefreshDescription(sender, eventArgs) {
                    var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                    ajaxManager.ajaxRequestWithTarget("<%= CountriesListBox.UniqueID %>", sender.get_selectedItem().get_text());
                }
            </script>

        </telerik:RadCodeBlock>
        
        <div class="demoMain">
        
        <ul class="demoUL">
            <li><a id="aEU" href="#" onclick="return InitiateAsyncRequest('Europe');">Europe</a></li>
            <li><a id="aNA" href="#" onclick="return InitiateAsyncRequest('NorthAmerica');">North America</a></li>
            <li><a id="aSA" href="#" onclick="return InitiateAsyncRequest('SouthAmerica');">South America</a></li>
            <li><a id="aAS" href="#" onclick="return InitiateAsyncRequest('Asia');">Asia</a></li>
            <li><a id="aAF" href="#" onclick="return InitiateAsyncRequest('Africa');">Africa</a></li>
            <li><a id="aAU" href="#" onclick="return InitiateAsyncRequest('Australia');">Australia</a></li>
        </ul>
        
        <asp:Panel ID="RadListBoxPanel" runat="server" CssClass="countryList">
            <h3><asp:Label ID="lblTitle2" runat="server" /></h3>
            <telerik:RadListBox ID="CountriesListBox" runat="server" Skin="Sunset" Width="100%"
                OnClientSelectedIndexChanged="RefreshDescription" OnSelectedIndexChanged="CountriesListBox_SelectedIndexChanged" Visible="false" />
        </asp:Panel>
        
        <asp:Panel ID="Panel1" runat="server" CssClass="descriptionText">
            <h3><asp:Label ID="lblTitle" runat="server" /></h3>
            <asp:Label ID="lblDescription" runat="server" />
        </asp:Panel>
        
        </div>

        <!-- content end -->
        <telerik:Footer runat="server" ID="Footer1"></telerik:Footer>
        </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