JS error when using setActive

5 posts, 1 answers
  1. WolveFred
    WolveFred avatar
    4 posts
    Member since:
    Sep 2011

    Posted 26 Sep 2011 Link to this post


    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");
    // 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">
            <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">
  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 26 Sep 2011 Link to this post

    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");

    I hope that helps.
  3. WolveFred
    WolveFred avatar
    4 posts
    Member since:
    Sep 2011

    Posted 26 Sep 2011 Link to this post

    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.
  4. Answer
    Marin Bratanov
    Marin Bratanov avatar
    4609 posts

    Posted 27 Sep 2011 Link to this post

    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.

    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
  5. WolveFred
    WolveFred avatar
    4 posts
    Member since:
    Sep 2011

    Posted 27 Sep 2011 Link to this post

    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 !
Back to Top