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

[Solved] Adding AjaxSettings in AjaxRequest handler results in wrong ClientID

1 Answer 251 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Afonso Mendes
Top achievements
Rank 1
Afonso Mendes asked on 16 Aug 2007, 10:54 AM

Hello,
I changed my project to Prometheus and I start getting a error like:
"Cannot find update panel with id: ctl00_ctl00_Content1_Button1"

The update control ControlID server side is ctl00_Content1_Button1 but in client side it’s wrongly formed. It seems to me that it depends from the relative path between the AjaxManager and the control to update.
Later I understood that this happens because I had the AjaxSetting on the AjaxRequest handler. The previous version of RadAjaxManager supported this perfectly, Prometheus does not. I must add the setting during OnLoad.

In my project the control to update depends of AjaxRequestEventArgs Argument. I think this is an important feature that you should implement in the future.

I added a small example showing the problem I described.

Best regards,
Tiago Veiga.

Master.master

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> 
 
<!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>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
    <telerik:RadAjaxManager ID="AjaxManager" runat="server" ></telerik:RadAjaxManager> 
    <div> 
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">  
        </asp:contentplaceholder> 
        <asp:contentplaceholder id="ContentPlaceHolder2" runat="server">  
        </asp:contentplaceholder> 
        <asp:contentplaceholder id="ContentPlaceHolder3" runat="server">  
        </asp:contentplaceholder> 
    </div> 
    </form> 
    <telerik:RadCodeBlock ID="cb1" runat="server">   
        <script type="text/javascript">  
            function DoCallBack(panelnumber)  
            {  
                <%= AjaxManager.ClientID %>.AjaxRequest(panelnumber);  
            }  
        </script> 
    </telerik:RadCodeBlock> 
</body> 
</html> 

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/MasterPage.master" %> 
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">  
<asp:LinkButton ID="lb1" Text="Update Content1!" runat="server" OnClientClick="DoCallBack('1'); return false;" /> 
<asp:LinkButton ID="lb2" Text="Update Content2!" runat="server" OnClientClick="DoCallBack('2'); return false;" /> 
</asp:Content> 
 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">  
    <asp:Label ID="lab1" runat="server" Text="Label1"/> 
</asp:Content> 
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder3" runat="Server">  
    <asp:Label ID="lab2" runat="server" Text="Label2"/> 
</asp:Content> 

Default.aspx.cs
using System;  
using System.Data;  
using System.Configuration;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
 
using Telerik.Web.UI;  
 
public partial class _Default : System.Web.UI.Page   
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        RadAjaxManager ajaxmanager = (RadAjaxManager)Page.Master.FindControl("AjaxManager");  
        ajaxmanager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(ajaxmanager_AjaxRequest);  
 
        ajaxmanager.AjaxSettings.AddAjaxSetting(ajaxmanager, lab2);  
    }  
 
    void ajaxmanager_AjaxRequest(object sender, AjaxRequestEventArgs e)  
    {  
        switch (e.Argument)  
        {  
            case "1":  
                lab1.Text = "Label1 " + DateTime.Now.Ticks;  
                (sender as RadAjaxManager).AjaxSettings.AddAjaxSetting((Control)sender, lab1);  
                break;  
            case "2":  
                lab2.Text = "Label2 " + DateTime.Now.Ticks;  
                break;  
            default:  
                break;  
        }  
    }  

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 16 Aug 2007, 11:16 AM
Hi Afonso,

Try using the AjaxSettingCreating/Created event handlers for these purposes, when using the Prometheus manager. This depends on the MS AJAX architecture and we do not believe that we can change that, so it would work in the AjaxRequest (which is actually UpdatePanel.Update()).

All the best,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Ajax
Asked by
Afonso Mendes
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or