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

[Solved] RadAjaxManager and AjaxControlToolkit

1 Answer 263 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Chris Predeek
Top achievements
Rank 1
Chris Predeek asked on 17 Oct 2007, 07:58 AM
I've run into a problem when I use an RadAjaxManager on a control that contains controls from the AjaxControlToolkit.  It seems the minimal amount of code to cause the problem is to take a control deriving from INamingContainer such as a wizard and either place it in a RadAjaxPanel or reference it in a RadAjaxManager.  Then place an AjaxControlToolkit control such as the MaskedEditControl on the page.

When an async postback occurs an "Object reference not set to an instance of an object." error is thrown. 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
 
<script type="text/C#" runat="server">  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        foreach (ScriptReference reference in ScriptObjectBuilder.GetScriptReferences(typeof(MaskedEditExtender)))  
            ScriptManager1.Scripts.Add(reference);  
    }  
</script> 
 
<!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>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" />                
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="Wizard1">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="Wizard1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
        <asp:Wizard ID="Wizard1" runat="server">  
            <WizardSteps> 
                <asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">  
                    Empty Step  
                </asp:WizardStep> 
                <asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2">  
                    <asp:TextBox ID="FaxPhone" runat="server" /> 
                    <ajaxToolkit:MaskedEditExtender ID="FaxPhoneEx" TargetControlID="FaxPhone" 
                        Mask="(999) 999-9999" ClearMaskOnLostFocus="false" MessageValidatorTip="true" 
                        MaskType="Number" ErrorTooltipEnabled="True" runat="server" /> 
                </asp:WizardStep> 
                <asp:WizardStep ID="WizardStep3" runat="server" Title="Step 3">  
                    Last Step  
                </asp:WizardStep> 
            </WizardSteps> 
        </asp:Wizard> 
    </form> 
</body> 
</html> 
 


A little debugging showed the error was coming from the ExtenderControlBase.GetScriptDescriptors method in the AjaxControlToolkit and the targetControl parameter provided was null.

I've found a temporary solution where I handle the OnPreRender event of each AjaxControlToolkit control and set it's TargetControlID to the UniqueID of the target control.  Is this a bug in the RadAjaxManager or is this temporary solution the correct solution?

protected void ExtenderControl_PreRender(object sender, EventArgs e)  
{  
    ExtenderControl control = sender as ExtenderControl;  
    control.TargetControlID = control.FindControl(control.TargetControlID).UniqueID;  

Thanks,
Chris

1 Answer, 1 is accepted

Sort by
0
Petja
Telerik team
answered on 22 Oct 2007, 09:05 AM
Hello Chris,

Thank you for contacting us.
The issue seems to be a bug in the Prometheus RadAjax controls. Our developers already fixed it and it will be included in the service pack release scheduled for this week. We have updated your Telerik points.
Let us know if you have further questions.

Sincerely yours,
Petja
the Telerik team

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