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

MSAjax Sys.InvalidOperationException

4 Answers 146 Views
Window
This is a migrated thread and some comments may be shown as answers.
sohrab
Top achievements
Rank 1
sohrab asked on 20 Aug 2008, 02:27 PM

We are actually encountering an error when trying to open a RadWindow.

Markup:

<

rad:RadWindowManager ID="rwmDocumentStatus" runat="server" Skin="Office2007" ClientCallBackFunction="CallBackFunctionDocumentStatus"

OnClientShow="OnClientShowDocumentStatus"

OnClientClose="OnClientCloseDocumentStatus">

<windows>

<rad:RadWindow ID="rw_StatusSelection" runat="server" Width="400px" Height="275px" NavigateUrl="./UserControls/SubDialogs/DocumentStatus.aspx"

Modal="True" Left="" Title="" Top="" />

</windows>

</rad:RadWindowManager>

On Button Click we first this javascript function:

function

ShowSaveOptions()

{

var oWnd = window.radopen(null, "rw_StatusSelection");

if (oWnd.GetUrl())

oWnd.SetUrl(oWnd.GetUrl());

else

{

OnClientShowDocumentStatus(oWnd);

oWnd.SetUrl(radWindowNavigateURL);

oWnd.SetHeight(275);

oWnd.SetWidth(400);

oWnd.OnClientClose =

"OnClientCloseDocumentStatus";

}

}


On the line "var oWnd = window.radopen(null, "rw_StatusSelection") the error
"Sys.InvalidOperationException: Two components with the same id 'rw_StatusSelection' cant be added" is thrown.

There is only one RadWindow with that ID. So I debugged the code and saw that the error is thrown by this piece of code (Microsoft.Ajax.js.debug).

function

Sys$_Application$addComponent(component) {

/// <param name="component" type="Sys.Component"></param>

var e = Function._validateParams(arguments, [

{name:

"component", type: Sys.Component}

]);

if (e) throw e;

var id = component.get_id();

if (!id) throw Error.invalidOperation(Sys.Res.cantAddWithoutId);

if (typeof(this._components[id]) !== 'undefined') throw Error.invalidOperation(String.format(Sys.Res.appDuplicateComponent, id));

this._components[id] = component;

}

Environment Info:
There is a RadEditor in a TabPanel. When the button is clicked the user tries to update/insert a new article, which was writtein the RadEditor. On the Save Button click the radwindow should be opened and a special state has to be selected how the article should be saved. The Radwindow works fine when we start with an empty RadEditor. But when we update an article (when the Editor was filled with text at page load) the mentioned error is thrown. In both cases (new and filled editor) the button click is executing the same code.

4 Answers, 1 is accepted

Sort by
0
sohrab
Top achievements
Rank 1
answered on 21 Aug 2008, 07:36 AM
I found out that this error is only happening when the rad window is opened AFTER a postback. When I try to open a window when no postback has yet happened everything is working as expected. But if I do any other action on the page causing a postback and then try to open the window the error occurs.

So I debugged the code and found in MicrosoftAjax.debug.js, line 3974 the function, which is actually throwing the error.
In the line 3983 it checks whether or not a control has been added to the components collection yet. If it already exists in the control collection it throws an error.

if

(typeof(this._components[id]) !== 'undefined') throw Error.invalidOperation(String.format(Sys.Res.appDuplicateComponent, id));

this

._components[id] = component;


So I changed the code in the MicrosoftAjax.debug.js so that it is not throwing an error anymore and instead adds the control id only when it doesnt exist in the collection yet.

if

(typeof(this._components[id]) === 'undefined') //throw Error.invalidOperation(String.format(Sys.Res.appDuplicateComponent, id));

{

this._components[id] = component;

}

This of course is a work around and I hope that you address this issue in the near future

Legend:
component = RadWindowManager
this._component[id] = ID of the RadWindow

function

Sys$_Application$addComponent(component) {

/// <param name="component" type="Sys.Component"></param>

var e = Function._validateParams(arguments, [

{name:

"component", type: Sys.Component}

]);

if (e) throw e;

var id = component.get_id();

if (!id) throw Error.invalidOperation(Sys.Res.cantAddWithoutId);

if (typeof(this._components[id]) === 'undefined') //throw Error.invalidOperation(String.format(Sys.Res.appDuplicateComponent, id));

{

this._components[id] = component;

}

}

0
Georgi Tunev
Telerik team
answered on 22 Aug 2008, 11:19 AM
Hi Sohrab,

Seems that you are not using postbacks but AJAX requests - otherwise you cannot receive such error. Unfortunately without having a better view over your exact setup, we cannot be of much help.

The only suggestion that I can give at this point is to make sure that the RadWindowManager is not Ajaxified - put it outside of the ajax panel or exclude it from the RadAjaxManager's (if you are using it) updated controls.

If you still experience this problem, please open a support ticket and send us a full, working, sample project where this error can be reproduced. We will check it and do our best to help.



Kind regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
sohrab
Top achievements
Rank 1
answered on 22 Aug 2008, 12:35 PM
The RadWindow is not ajaxified. I am going to open a support ticket.

Thanks,
sohab
0
sohrab
Top achievements
Rank 1
answered on 25 Aug 2008, 10:11 AM
With this forum post we were able to get it working, too!
http://www.telerik.com/community/forums/thread/b311D-bcemcg.aspx

This is how our markup looks like now:

<

asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

<rad:RadAjaxManager ID="RadAjaxManager1" runat="server"></rad:RadAjaxManager>

<rad:RadWindowManager ID="rwmDocumentStatus" runat="server" Skin="Office2007" ClientCallBackFunction="CallBackFunctionDocumentStatus"

OnClientShow="OnClientShowDocumentStatus"

OnClientClose="OnClientCloseDocumentStatus">

<windows>

<rad:RadWindow ID="rw_StatusSelection" runat="server" Width="400px" Height="275px" NavigateUrl="./UserControls/SubDialogs/DocumentStatus.aspx"

Modal="True" Left="" Title="" Top="" />

</windows>

</rad:RadWindowManager>


Tags
Window
Asked by
sohrab
Top achievements
Rank 1
Answers by
sohrab
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or