This is a migrated thread and some comments may be shown as answers.

AjaxManager: Always update a control

3 Answers 168 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Geert
Top achievements
Rank 1
Geert asked on 06 Nov 2008, 09:16 AM
Hello,

Scenario:
Masterpage with content pages, In the masterpage there is a control we made called an errorcontrol which displays errors if the content generated them.
The content is placed dynamically so we now have to set all ajaxsettings in codebehind and for updating the errorcontrol we push the control through to all subcontrols (sometimes 5 deep)

Is it possible to implement that no matter what control fires an ajaxrequest, the errorcontrol will always be updated on the page??

Hope this is clear enough.

Thanks in advance,

The SOFIM-team (Belgium)

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 07 Nov 2008, 01:18 PM
Hi Geert,

In order to achieve the required functionality, you could use ajaxRequest or ajaxRequestWithTarget functions of the RadAjax controls. For more information on this functions, please review the following help topic.

Regards,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kevin Babcock
Top achievements
Rank 1
answered on 08 Nov 2008, 03:08 AM
Hi Geert,

You should use a RadAjaxManager on your master page and then RadAjaxManagerProxy controls on your content pages. When creating the AjaxSettings dynamically in your content page code-behind, simply get a reference to the RadAjaxManager on the master page and add an AjaxSetting which causes each control to update the error control on your Master Page.

Here is a quick example:

Master.Master
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Master.master.cs" Inherits="Telerik.Examples.Master" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title>Example - Always Updating a Control with the RadAjaxManager</title> 
</head> 
<body> 
    <form id="form1" runat="server"
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />       
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" />       
        <asp:Label ID="lblTimeMaster" runat="server" />      
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server" /> 
    </form> 
</body> 
</html> 
 

Master.Master.cs
using System; 
 
namespace Telerik.Examples 
    public partial class Master : System.Web.UI.MasterPage 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            lblTimeMaster.Text = DateTime.Now.ToString(); 
        } 
    } 
 

Default.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Telerik.Examples.Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="Button1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lblTime" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManagerProxy> 
 
    <asp:Label ID="lblTime" runat="server" /> 
     
    <asp:Button ID="Button1" runat="server" Text="Click Me!" /> 
</asp:Content> 
 

Default.aspx.cs
using System; 
using System.Web.UI; 
using Telerik.Web.UI; 
 
namespace Telerik.Examples 
    public partial class Default : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            var ajaxManager = Page.Master.FindControl("RadAjaxManager1"as RadAjaxManager; 
            if (ajaxManager != null
            { 
                var setting = new AjaxSetting("Button1"); 
                var updatedControl = new AjaxUpdatedControl { ControlID = "lblTimeMaster" }; 
                setting.UpdatedControls.Add(updatedControl); 
                ajaxManager.AjaxSettings.Add(setting); 
            }            
 
            lblTime.Text = DateTime.Now.ToLongTimeString(); 
        } 
    } 
 

I hope this helps. If you have further questions, please let me know.

Sincerely,
Kevin Babcock
0
appdev
Top achievements
Rank 1
answered on 20 Apr 2012, 05:00 AM
       
Tags
Ajax
Asked by
Geert
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Kevin Babcock
Top achievements
Rank 1
appdev
Top achievements
Rank 1
Share this question
or