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

Getting error ..Microsoft JScript runtime error: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method

6 Answers 194 Views
Window
This is a migrated thread and some comments may be shown as answers.
Shahid
Top achievements
Rank 1
Shahid asked on 07 Jun 2010, 12:56 PM
From the content page we open a radwindow in which we have a radGrid. OnRowDoubleclick of that radGrid we have a function which makes an Ajax call to the server side through the RadAjax manager. Now in the function onAjaxRequest end we have code to close the opened RadWindow. which is giving me this error.

function CloseRadWindow()
            {
                var oManager = parent.GetRadWindowManager();                     
                var oWnd = oManager.getActiveWindow();
                if (oWnd != null)
                {                    
                    oWnd.close();                    
                }
                return false;
            }

RadWindowManager is present on the parent page.

This code works fine (closes the radWindow if we do not make any AjaxRequest to searver side).
Do we have any work around to fix this Issue?

6 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 10 Jun 2010, 10:35 AM
Hello Shahid,

The provided information was not enough for me to recreate your scenario. Could you please open a new support ticket and send me runnable project which shows the problem? I will check it and do my best to provide a working solution as soon as possible.

Greetings,
Fiko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Srikanth
Top achievements
Rank 1
answered on 28 Sep 2010, 04:08 PM
Hi,

I opened Radwindow from Parent Window.

Radwindow opening fine. After close Radwindow, i have to call javascript function in parent window. for that i used below code:

codebehind in Radwindow :
--------------------------------
public void btnAddtoCaseSheet_Click()
{
 Response.Write("<script language='javascript'>GetRadWindow().BrowserWindow.RefreshCaseHistory();</script>");
or
   ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "refreshParent();", true);
}
Javascript in Radwindow:
-------------------------------

         <asp:Button ID="btnAddtoCaseSheet" runat="server" Text="Add to CaseSheet"
             OnClientClick="Close()" onclick="btnAddtoCaseSheet_Click"/>
   
     <script language ="javascript" type ="text/javascript" >
    
      function GetRadWindow() {
          var oWindow = null;
          if (window.radWindow)
              oWindow = window.RadWindow; //Will work in Moz in all cases, including clasic dialog     
          else if (window.frameElement.radWindow)
              oWindow = window.frameElement.radWindow; //IE (and Moz as well)     
          return oWindow;
      }
      function refreshParent() {
// caseHistory() function is ParentWindow Javascript function
          GetRadWindow().BrowserWindow.CaseHistory(); 
      }

      function Close() {

          GetRadWindow().Close();
     
      }         
</script> 




 but i am getting below error.

"Microsoft JScript runtime error: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method"

i am searching to resolve this error for the last 3 weeks. but, i didn't get... pls give reply ASAP.

Thanks and Regards,
Srikanth.


0
Georgi Tunev
Telerik team
answered on 01 Oct 2010, 12:19 PM
Hi Srikanth,

In your code, you use the OnClick and OnClientClick properties. In OnClientClick (which is executed first) you close the RadWindow and then try to execute a code from that same page that you closed (in OnClick's server event) which will lead to problems like this one.
If you need to use the server event of the button, remove the OnClientClick property and close the RadWindow in the refreshParent() function.
e.g.
function refreshParent()
{
   GetRadWindow().BrowserWindow.CaseHistory();
   GetRadWindow().close()
}


If you don't need the trip to the server, cancel the postback (OnClientClick = "Close(); return false;") and again call the function on the parent and close the RadWindow in the same order.
e.g.
function Close()
{
   GetRadWindow().BrowserWindow.CaseHistory();
   GetRadWindow().close()
}




Best wishes,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Srikanth
Top achievements
Rank 1
answered on 02 Oct 2010, 04:47 AM
Hi Georgi Tunev,

Thanks for your reply. But,no luck.... still i am getting same Javascript run-time error.

As you said,i removed OnclientClick property and close the RadWindow in the refreshParent() function.
e.g.
function refreshParent()
{
   GetRadWindow().BrowserWindow.CaseHistory();
   GetRadWindow().close()
}

code behind :
-----------------
 ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "refreshParent();", true);

Thanks and Regards,
Srikanth.
0
Srikanth
Top achievements
Rank 1
answered on 02 Oct 2010, 04:54 AM
Hi Georgi Tunev,

if i use below code in code-behind, i am getting "Microsoft JavaScript run-time error: Object expected" .

 Response.Write("<script language='javascript'>GetRadWindow().BrowserWindow.CaseHistory();</script>");

" CaseHistory" function is parent-window JavaScript function.


Thanks and Regards,
Srikanth.
0
Georgi Tunev
Telerik team
answered on 04 Oct 2010, 11:39 AM
Hello Srikanth,

Make sure that the JavaScript function that you try to call is actually executed - for example you could put a simple alert in the beginning of the refreshParent() function and see if it is called again. Once ensure that the alert is shown, your code should work without problems.
If you still experience problems with this solution, please open a support ticket and send a sample project so we can investigate further.

Greetings,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
Shahid
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Srikanth
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or