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

JS error when using setActive

4 Answers 169 Views
Window
This is a migrated thread and some comments may be shown as answers.
WolveFred
Top achievements
Rank 1
WolveFred asked on 26 Sep 2011, 10:44 AM
Hi,

I have got a problem when using the setActive Javascript function on a RadWindow. The error is :
"Sys.ArgumentNullException: Value cannot be null.Parameter name: element".

I don't understand why the parameter is null. The parameter corresponds to oWnd._popupElement.

May anyone help me fixing this error ?

Below is an extract of the Javascript code that generates the exception :

// 1) User-code file, launched at body:onLoad() event
var oWnd = $find("helpWindow");
oWnd.setSize(400,500);
oWnd.setActive(false);
 
// 2) Telerik code file
setActive:function(c){var f=this._popupElement;
if(!c){Sys.UI.DomElement.addCssClass(f,"rwInactiveWindow"); // f is null
[...]
 
// 3) Microsoft ASP.Net Ajax code file
Sys.UI.DomElement.addCssClass = function Sys$UI$DomElement$addCssClass(element, className) {
    /// <summary locid="M:J#Sys.UI.DomElement.addCssClass" />
    /// <param name="element" domElement="true"></param>
    /// <param name="className" type="String"></param>
    var e = Function._validateParams(arguments, [
        {name: "element", domElement: true},
        {name: "className", type: String}
    ]);
    if (e) throw e; // The exception is thrown here
    if (!Sys.UI.DomElement.containsCssClass(element, className)) {
        if (element.className === '') {
            element.className = className;
        }
        else {
            element.className += ' ' + className;
        }
    }
}

The RadWindow that is used is described in the following aspx code-file :

<telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"
    ReloadOnShow="true" runat="server" EnableShadow="true">
    <Windows>
        <telerik:RadWindow ID="HelpWindow" runat="server" NavigateUrl="Help.aspx"
            ReloadOnShow="true" VisibleOnPageLoad="false" ShowContentDuringLoad="false"
            Behaviors="Close, Maximize, Resize" Width="500px" Height="400px" Modal="true"
            Animation="Fade" KeepInScreenBounds="true" RestrictionZoneID="form2" AutoSizeBehaviors="Height">
        </telerik:RadWindow>

4 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 26 Sep 2011, 01:17 PM
Hello WolveFred,

The reason it throws an error is because the RadWindow object hasn't been created yet, which is the reason your code fails. You should change your code to this:

function pageLoad(){
    var oWnd = $find("helpWindow");
    oWnd.setSize(400,500);
    oWnd.setActive(false);
}

I hope that helps.
0
WolveFred
Top achievements
Rank 1
answered on 26 Sep 2011, 03:58 PM
Hi Kevin,

Thanks for your answer.

But that didn't work. I understood that pageLoad() is a ASP.NET AJAX shortcut function. So I put this code in this function instead of in the body onLoad. But no change in the thrown exception.

In addition, the same code, called in the window.onresize event, throw the same exception. So I'm wondering when calling that code.

Thanks for your help.
0
Accepted
Marin Bratanov
Telerik team
answered on 27 Sep 2011, 09:34 AM
Hello guys,

The RadWindow renders its markup only after it is first shown, i.e. all its elements do not exist on the page before this point. The setActive() method needs these elements so that it can set proper z-index values, css classes, etc. What it seems happens in your scenario is that you call this function too early - you do not have an opened RadWindow so this method should not be called. You can call it after the show() or radopen() methods, yet I hardly believe it is necessary. Its intended use is managing multiple windows through code, for example when simulating a desktop MDI environment and you need to show a certain RadWIndow after a user action.


Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
WolveFred
Top achievements
Rank 1
answered on 27 Sep 2011, 02:03 PM
Hi Marin,

You were right : the RadWindows weren't displayed at this stage.
So before I called setActive, I test now if the window is visible with the "isVisible()" function.

Thank you !
Tags
Window
Asked by
WolveFred
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
WolveFred
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or