AjaxManager - Dynamic AjaxSettings

Next database reset in 1 hours, 42 minutes, 2 seconds
     Add new employee                    Delete selected employee                    Refresh employees list
1NancyDavolioSales RepresentativeMs.12/08/1948Education includes a BA in psychology from Colorado State University in 1970. She also completed "The Art of the Cold Call." Nancy is a member of Toastmasters International.
2AndrewFullerVice President, SalesDr.02/19/1952Andrew received his BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.
3JanetLeverlingSales RepresentativeMs.08/30/1963Janet has a BS degree in chemistry from Boston College (1984). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate in 1991 and promoted to sales representative in February 1992.
4MargaretPeacockSales RepresentativeMrs.09/19/1937Margaret holds a BA in English literature from Concordia College (1958) and an MA from the American Institute of Culinary Arts (1966). She was assigned to the London office temporarily from July through November 1992.
5StevenBuchananSales ManagerMr.03/04/1955Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree in 1976. Upon joining the company as a sales representative in 1992, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London. He was promoted to sales manager in March 1993. Mr. Buchanan has completed the courses "Successful Telemarketing" and "International Sales Management." He is fluent in French.
6MichaelSuyamaSales RepresentativeMr.07/02/1963Michael is a graduate of Sussex University (MA, economics, 1983) and the University of California at Los Angeles (MBA, marketing, 1986). He has also taken the courses "Multi-Cultural Selling" and "Time Management for the Sales Professional." He is fluent in Japanese and can read and write French, Portuguese, and Spanish.
7RobertKingSales RepresentativeMr.05/29/1960Robert King served in the Peace Corps and traveled extensively before completing his degree in English at the University of Michigan in 1992, the year he joined the company. After completing a course entitled "Selling in Europe," he was transferred to the London office in March 1993.
8LauraCallahanInside Sales CoordinatorMs.01/09/1958Laura received a BA in psychology from the University of Washington. She has also completed a course in business French. She reads and writes French.
9AnneDodsworthSales RepresentativeMs.01/27/1966Anne has a BA degree in English from St. Lawrence College. She is fluent in French and German.
Isolate this demo as a stand-alone application
  • About this demo
  • C#
  • VB
This example demonstrates how to perform edit/update/delete/insert operations in RadGrid using an external form for this purpose.

The sample focuses on how to AJAX-enable a RadGrid control programmatically (when residing in a user control) and use the edit/add buttons in the grid individually (intercepting the ItemCreated server event of the control - see the RadAjaxManager -> Partial Ajaxificationdemo for reference). The sample also illustrates how to change the declaratively set AJAX settings for the update/delete/insert buttons from the external form to update the grid instance instead of the form itself. This is done by intercepting the OnAjaxSettingCreating event of the RadAjaxManager in which we determine the initiator of the AJAX request and change the updated control dynamically.

  • Click the Edit icon in a grid row to edit its date in an external form.
  • Click the 'Add new employee' button in the command item to insert a new grid row through an external form.
  • Delete grid items by either selecting a row and clicking the 'Delete selected employee' link at the top of the grid or choose to edit a row and then press the 'Delete' button from the external form.
  • defaultcs.aspx
  • EmployeesGridCS.ascx
  • defaultcs.aspx.cs
    • defaultcs.aspx.cs
    • EmployeesGridCS.ascx.cs
  • scripts.js
  • styles.css
<%@ Page Language="c#" CodeFile="defaultcs.aspx.cs" AutoEventWireup="false" 
    Inherits="Telerik.AjaxManager.ServerSideProgramming.DynamicAjaxSettings.DefaultCS" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register Src="EmployeesGridCS.ascx" TagName="EmployeesGrid" TagPrefix="uc1" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<!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">
    <title>Telerik ASP.NET Example</title>
    <link href='<%= HttpUtility.HtmlEncode(Page.ClientScript.GetWebResourceUrl(typeof(RadEditor), "Telerik.Web.UI.Skins.Editor.css")) %>'
        rel="stylesheet" type="text/css" />
    <link href="styles.css" rel="stylesheet" type="text/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 ">
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript" src="scripts.js"></script>
        </telerik:RadCodeBlock>

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxSettingCreating="RadAjaxManager1_AjaxSettingCreating">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btnSaveChanges">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="DivExternalForm" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="btnDelete">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="DivExternalForm" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>

        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />

        <telerik:RadWindowManager RenderMode="Lightweight" ID="RadWindowManager1" runat="server" />

        <uc1:EmployeesGrid ID="EmployeesGrid1" runat="server" />

        <div id="DivExternalForm" runat="server" class="editPanel">
            <asp:Panel ID="pnlExternalForm" runat="server" Visible="false">
                <table border="0" style="margin-top: 20px; width: 100%;">
                    <tr>
                        <td colspan="2">
                            <div class="buttonsContainer">
                                <telerik:RadButton RenderMode="Lightweight" ID="btnSaveChanges" Text="Save" runat="server" OnClientClicked="processUpdate"
                                    OnClick="SaveChanges_Click" />
                                <telerik:RadButton RenderMode="Lightweight" ID="btnDelete" OnClientClicked="processDelete" Text="Delete"
                                    runat="server" OnClick="Delete_Click" />
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 100px;">Employee ID:
                        </td>
                        <td>
                            <asp:Label ID="EmployeeID" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>Last name:
                        </td>
                        <td>
                            <telerik:RadTextBox RenderMode="Lightweight" ID="LastName" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>First name:
                        </td>
                        <td>
                            <telerik:RadTextBox RenderMode="Lightweight" ID="FirstName" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>Title:
                        </td>
                        <td>
                            <telerik:RadTextBox RenderMode="Lightweight" ID="Title" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>Title of courtesy:
                        </td>
                        <td>
                            <telerik:RadComboBox RenderMode="Lightweight" ID="TitleOfCourtesy" runat="server">
                                <Items>
                                    <telerik:RadComboBoxItem Text="" Value="" />
                                    <telerik:RadComboBoxItem Text="Dr." Value="Dr." />
                                    <telerik:RadComboBoxItem Text="Mr." Value="Mr." />
                                    <telerik:RadComboBoxItem Text="Mrs." Value="Mrs." />
                                    <telerik:RadComboBoxItem Text="Ms." Value="Ms." />
                                </Items>
                            </telerik:RadComboBox>
                        </td>
                    </tr>
                    <tr>
                        <td>Birth date:
                        </td>
                        <td>
                            <telerik:RadDatePicker RenderMode="Lightweight" ID="BirthDate" MinDate="01/01/1900" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td style="vertical-align: top;">Notes:
                        </td>
                        <td style="height: 300px; vertical-align: top;">
                            <telerik:RadEditor RenderMode="Lightweight" ID="Notes" Width="400px" runat="server" Height="250px">
                                <Tools>
                                    <telerik:EditorToolGroup>
                                        <telerik:EditorTool Name="Italic" />
                                        <telerik:EditorTool Name="Bold" />
                                        <telerik:EditorTool Name="Underline" />
                                        <telerik:EditorTool Name="StrikeThrough" />
                                        <telerik:EditorTool Name="JustifyLeft" />
                                        <telerik:EditorTool Name="JustifyCenter" />
                                        <telerik:EditorTool Name="JustifyRight" />
                                        <telerik:EditorTool Name="JustifyFull" />
                                    </telerik:EditorToolGroup>
                                </Tools>
                            </telerik:RadEditor>
                        </td>
                    </tr>
                </table>
            </asp:Panel>
        </div>
    </div>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance

Help Us Improve

Was this example helpful?