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

RadAjaxPanel.AjaxPanelRequestEventHandler vs RadAjaxControl.AjaxRequestDelegate

3 Answers 170 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Olga
Top achievements
Rank 1
Olga asked on 09 Mar 2011, 05:18 AM
Hi,

I am upgrading an application from Classic Telerik controls to the latest ASP.NET AJAX ones.  I have replaced the following line of code

AjaxPanel.AjaxRequest -=

 

new RadAjaxPanel.AjaxPanelRequestEventHandler(ContentPaneControl_AjaxRequest);

 


with this one:

AjaxPanel.AjaxRequest -=

 

new RadAjaxControl.AjaxRequestDelegate(ContentPaneControl_AjaxRequest);

 


because the former would no longer compile.

It's crazy, but I can't even find where I got the idea for the second line.  Anyway, the problem is that it works with some of my controls but not with others.  For some controls it goes into ContentPaneControl_AjaxRequest, for others - it doesn't.  The code is all in one script.  They all go to that same script.

Any ideas?

Thanks,
Olga

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 14 Mar 2011, 01:07 PM
Hello Olga,

The RadAjaxControl.AjaxRequestDelegate is the new delegate type to use for the AjaxRequest event of the RadAjaxManager and RadAjaxPanel controls. The previous event handler type no longer exists in the Telerik.Web.UI assembly. The issue you are describing seems to be related to when the event handler is attached and detached to the AjaxRequest event. If you can show us some sample code we can examine, we may be able to identify the exact cause for this.

Veli
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Olga
Top achievements
Rank 1
answered on 15 Mar 2011, 12:29 AM
protected override void OnLoad(EventArgs e)
        {
            AjaxPanel.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(ContentPaneControl_AjaxRequest); 
            TemplateSelector.SelectionChanged += new SelectedChangedDelegate(TemplateSelector_SelectionChanged);
  
            if (!this.IsPostBack)
            {
                this.TemporarySessionId = Guid.NewGuid();
            }
  
            base.OnLoad(e);
        }

void ContentPaneControl_AjaxRequest(object source, AjaxRequestEventArgs e)
        {
            if (e.Argument.StartsWith("useComboItem"))
            {
                int index1 = e.Argument.IndexOf(";");
                int index2 = e.Argument.IndexOf(";", index1 + 1); // Do not use LastIndexOf beacuse name can contain semicolumn
                int index3 = e.Argument.IndexOf(";", index2 + 1);
  
                string userControlId = e.Argument.Substring(index1 + 1, index2 - index1 - 1);
                string selectionSetType = e.Argument.Substring(index2 + 1, index3 - index2 - 1);
                string text = e.Argument.Substring(index3 + 1);
  
                // Update dropdowns on this page which contains selection sets of the specified type
                PopulateDropDowns(selectionSetType);
  
                ISelectionSetSelectorUserControlOnTemplatePage userControl = Util.GetContentPlaceHolder(Page.Master).FindControl(userControlId) as ISelectionSetSelectorUserControlOnTemplatePage;
                if (userControl != null)
                {
                    userControl.OnUse(selectionSetType, text);
                }
            }

Like I said, both of these are in the same base class.  All of my RadComboBox controls go through the top event, but some don't go through the bottom method.  This was working fine for all controls before the Classic to ASP.NET AJAX upgrade.  There is no difference between the way the controls are set up.

Thanks,
Olga
0
Veli
Telerik team
answered on 15 Mar 2011, 12:11 PM
Hello Olga,

The code you provided seems fine. Try the OnInit method instead of OnLoad just to make sure the event handlers are not attached later than the point the respective event is fired. Other than that, the approach seems correct. Are you sure the problem with the event handlers not getting called is caused by the handlers not getting attached?

Veli
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
Olga
Top achievements
Rank 1
Answers by
Veli
Telerik team
Olga
Top achievements
Rank 1
Share this question
or