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.
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?
Thanks,
Chris
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