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

UpdatePanel in ContentTemplate - Unregister error

8 Answers 167 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 05 Apr 2016, 03:13 PM

I am dynamically generating a RadWindow with an AJAX UpdatePanel added to it's ContentTemplate in my custom server control (during the control's Init event) like so:

_updatePanel = new UpdatePanel() { ID = string.Format("{0}_UpdatePanel", ID), UpdateMode = UpdatePanelUpdateMode.Conditional };
_modalWindow = new RadWindow();
_modalWindow.ID = string.Format("{0}_radWindow", ID);
_modalWindow.ContentContainer.Controls.Add(_updatePanel);

The server control with said RadWindow is also dynamically declared in a RadGrid's GridTemplateColumn. The idea is when the user edits a RadGrid record that contains a RadComboBox the user can view/edit the details of the selected RadComboBox item in a RadWindow popup. This all works fine until I attempt to hit the Save or Cancel button on the RadGrid to close edit mode.

I am aware of the following posts that describe why the error is happening but I am not sure how to go about solving this in my situation.

http://www.telerik.com/support/kb/aspnet-ajax/window/details/cannot-unregister-updatepanel-with-id-updatepanelid-since-it-was-not-registered-with-the-scriptmanager-error

http://www.telerik.com/forums/is-a-partial-postback-with-radwindow-possible

It seems the solution is to declare the RadWindow directly on the page. The problem is I am developing a server control, would it work if I got a reference to the Page and added it directly instead of to the ControlCollection of my server control?

 

Thanks!

 

8 Answers, 1 is accepted

Sort by
0
Jonathan
Top achievements
Rank 1
answered on 06 Apr 2016, 12:37 PM

To be clear, the error I am receiving is as follows:

Cannot unregister UpdatePanel with ID 'UpdatePanelID' since it was not registered with the ScriptManager.

I know the reason for this is that the UpdatePanel has been moved from it's location inside my custom control to the first child of the Form on the page. I guess then this messes up the ScriptManager because it is trying to unregister a control that it cannot find?

Also, some information that may be helpful. I am not using the VisibleOnPageLoad property to show the RadWindow. I am using ScriptManager.RegisterStartupScript to find and show the RadWindow. 

0
Ianko
Telerik team
answered on 07 Apr 2016, 12:20 PM
Hello Jonathan,

I cannot guarantee you that adding the RadWindow instance to the page directly would be a solution. Also, it will be out of the UpdatePanel. And if this is so, why the UpdatePanel should be involved with RadWindow in the first place.

Why not using RadAjaxManager instead of UpdatePanel?

Regards,
Ianko
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Jonathan
Top achievements
Rank 1
answered on 08 Apr 2016, 12:08 PM

I'm using an UpdatePanel because the content in the RadWindow will post back to the server and I do not want the window to flash or the page to reload. I am not sure how I would use a RadAjaxManager in my scenario.

Also, it seems that adding the UpdatePanel to the page did work except I cannot actually show the modal now because of the way I was opening it, like so:

string script = "function showModal() { $find(\"" + _modalWindow.ClientID + "\").show(); Sys.Application.remove_load(showModal); } Sys.Application.add_load(showModal);";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), string.Format("{0}_ShowModal", ID), script, true);

The error I get is, could not find 'ModalWindowID'.

0
Ianko
Telerik team
answered on 11 Apr 2016, 06:44 AM
Hello Jonathan,

Using RadAjaxManager is documented here—http://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxmanager/overview. You can still use it programmatically. Where you can check if there is am AjaxManager on the page and just configure it further as per to you needs. Or you can use RadAajxManagerProxy if you have already declared a RadAjaxManager in the application. 

As for RadWindow modal behavior, the described situation is expected. With AJAX-enabled control, RadWindow cannot render its modal div element that is typically added at the end of the form. Where AJAX techniques cannot  enable adding DOM elements outside the UpdatePanel.

In this case, I suggest you rendering RadWindow without modal behavior and enabling it on the client by using the set_modal(true) method.
 
Regards,
Ianko
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Jonathan
Top achievements
Rank 1
answered on 11 Apr 2016, 12:23 PM

I just removed the modal behavior of the RadWindow by settings the Modal property to false (_modalWindow.Modal = false) on my server control and I am still experiencing the same issue. I also have EnableViewState = true - not sure if this makes a difference? I need the viewstate functionality though because the post backs on the control need to remember the values the user has entered.

I will attempt to use the RadAjaxManager next and report back. I appreciate your help.

0
Ianko
Telerik team
answered on 14 Apr 2016, 06:17 AM
Hello Jonathan,

I do not see how ViewState could be relevant to the case with the JS error.

Also, if the error is still the same when loading non-modal RadWindow, can you please provide a markup example of the issue so that I can properly understand the scenario?

Regards,
Ianko
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Jonathan
Top achievements
Rank 1
answered on 03 May 2016, 06:53 PM

So the only way I could fix this issue is by forcefully registering the UpdatePanel with the ScriptManager every time the UpdatePanel is unloaded. This seems like an unconventional fix and I am worried what repercussions this may have.

protected void UpdatePanel_Unload(object sender, EventArgs e) {MethodInfo methodInfo = typeof(ScriptManager).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(i => i.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel")).First(); methodInfo.Invoke(ScriptManager.GetCurrent(Page),new object[] { sender as UpdatePanel });}

0
Jonathan
Top achievements
Rank 1
answered on 03 May 2016, 06:54 PM
that fix was discovered in this post http://stackoverflow.com/questions/8727658/cannot-unregister-updatepanel-with-id-xxx-since-it-was-not-registered-with-th
Tags
Window
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Jonathan
Top achievements
Rank 1
Ianko
Telerik team
Share this question
or