UpdatePanel in MasterPage causes error
I have an UpdatePanel in my MasterPage and I get the following error
Hold off on looking into this. Both the MasterPage and a custom control both had an UpdatePanel with the same name. I removed the one from the MasterPage and I still had the issue.
Hi Eric,
Try using RadAjaxPanel with ScriptManager declared inside a control
<asp:ScriptManager ID="ScriptManager" runat="server"/><telerik:RadAjaxPanel id="RadAjaxPanel1" runat="server" EnableAJAX= "True"> <asp:Label ID="Label1" runat="server" /><br /> <asp:Button ID="Button2" runat="server" Text="Update" OnClick="Button1Test_Click" /> </telerik:RadAjaxPanel>protected void Button1Test_Click(object sender, EventArgs e) Label1.Text = DateTime.Now.ToLongTimeString(); Over the weekend, I saw this was an issue with 3.x also.
Hello Eric,
This issue is not related the the license. Do you have a problem when you use RadAjaxPanel and ScriptManager as my code shows?
Best wishes,
Ivan Dimitrov
the Telerik team
With that code, I keep getting a null reference exception
[NullReferenceException: Object reference not set to an instance of an object.] Telerik.Web.UI.RadAjaxControl.OnPagePreRender(Object sender, EventArgs e) +282
I get the same error if I switch the RadAjaxPanel with a regular Panel and add a RadAjaxManager.
Hi Eric,
I cannot reproduce this issue if I add the control inside the template from the backend UI or drop the control on a page, so you can use these options. The issue only appears if you hardcode the controls inside the .master file and we are going to investigate this issue.
Regards,
Ivan Dimitrov
the Telerik team
I have a workaround that seems to work, though I worry it may lead to memory leaks or something. In my ControlBase (which all my controls inherit from), when the control initializes, I check to see if the control is on a Sitefinity page and if it's in design mode, if so, I add an onload event handler to the each update panel in the control (using a Control extension method: FindControls). The event handler adds the UpdatePanel to the ScriptManager again, this time from when the control is in its final resting place.
protected override void OnInit(EventArgs e) if (Page is SitefinityRadPage && Page.IsDesignMode()) foreach (UpdatePanel up in this.FindControls<UpdatePanel>()) up.Load += UpdatePanel_Load; base.OnInit(e);private void UpdatePanel_Load(object sender, EventArgs e) UpdatePanel panel = sender as UpdatePanel; MethodInfo m = (from methods in typeof(ScriptManager).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance) where methods.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel") select methods).First(); if (panel == null || m == null) return; m.Invoke(ScriptManager.GetCurrent(Page), new object[] panel );