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

Update TargetControls with AJAX

ProductSupplierPrice
Page size:
10
31 Gorgonzola Telino Formaggi Fortini s.r.l.$12.50
32 Mascarpone Fabioli Formaggi Fortini s.r.l.$32.00
33 Geitost Norske Meierier$2.50
34 Sasquatch Ale Bigfoot Breweries$14.00
35 Steeleye Stout Bigfoot Breweries$18.00
36 Inlagd Sill Svensk Sjöföda AB$19.00
37 Gravad lax Svensk Sjöföda AB$26.00
38 Côte de Blaye Aux joyeux ecclésiastiques$263.50
39 Chartreuse verte Aux joyeux ecclésiastiques$18.00
40 Boston Crab Meat New England Seafood Cannery$18.40

There are situations when the RadToolTipManager's TargetControls collection should be updated. This example shows a common scenario when this should be done - it contains a RadGrid which has its paging and sorting turned on. Every time a page is changed or the grid is sorted, it is updated through AJAX and the RadToolTipManager's TargetControls collection should get updated, too. In order to achieve this, both the grid and the RadToolTipManager are ajaxified by using a RadAjaxManager control.

Note, that when the page index is changed, or a sorting has been done, the RadToolTipManager's TargetControls collection is cleared because the records on the new grid's page have the same ClientIDs as the old ones.

Move the mouse over a product name to see more details about it
  • DefaultVB.aspx
  • ProductDetailsVB.ascx
  • DefaultVB.aspx.vb
    • DefaultVB.aspx.vb
    • ProductDetailsVB.ascx.vb
  • styles.css
<%@ Page Language="vb" CodeFile="DefaultVB.aspx.vb" EnableViewStateMac="false" ViewStateEncryptionMode="Never"Inherits="Telerik.Web.Examples.ToolTip.TargetControlsAndAjax.DefaultVB"  %>

<%@ Register Src="ProductDetailsCS.ascx" TagName="ProductDetails" TagPrefix="uc1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link rel="Stylesheet" href="styles.css" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-medium">
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                        <telerik:AjaxUpdatedControl ControlID="RadToolTipManager1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadToolTipManager RenderMode="Lightweight" ID="RadToolTipManager1" OffsetY="-1" HideEvent="ManualClose"
            Width="250" Height="350" runat="server" OnAjaxUpdate="OnAjaxUpdate" RelativeTo="Element"
            Position="MiddleRight">
        </telerik:RadToolTipManager>
        <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1"
            GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound" AllowPaging="true"
            AllowSorting="true" PageSize="10" OnItemCommand="RadGrid1_ItemCommand">
            <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="None" CurrentResetPageIndexAction="SetPageIndexToFirst"
                DataKeyNames="ProductID" DataSourceID="SqlDataSource1" Dir="LTR" Frame="Border"
                TableLayout="Auto">
                <Columns>
                    <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="ProductID" Display="false"
                        DataType="System.Int32" FilterListOptions="VaryByDataType" ForceExtractValue="None"
                        HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" UniqueName="ProductID">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Product" SortExpression="ProductName">
                        <ItemTemplate>
                            <asp:HyperLink ID="targetControl" runat="server" NavigateUrl="#" Text='<%# Eval("ProductName") %>'></asp:HyperLink>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn AllowSorting="true" DataField="CompanyName" HeaderText="Supplier"
                        SortExpression="CompanyName" UniqueName="CompanyName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn AllowSorting="true" DataField="UnitPrice" DataFormatString="{0:C}"
                        HeaderText="Price" SortExpression="UnitPrice">
                    </telerik:GridBoundColumn>
                </Columns>
                <EditFormSettings>
                    <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType">
                    </EditColumn>
                </EditFormSettings>
                <PagerStyle PageSizeControlType="RadDropDownList" ShowPagerText="false" />
            </MasterTableView>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [Products] INNER JOIN [Suppliers] ON Products.SupplierID=Suppliers.SupplierID "></asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance