unable to locate radwindow object from radgrid_itemcommand event

3 posts, 1 answers
  1. Manisha Shivjiani
    Manisha Shivjiani avatar
    24 posts
    Member since:
    Nov 2009

    Posted 01 Mar 2012 Link to this post

    Hi,
    I am having issue accessing radwindow object. I am trying access it during radgrid_itemcommandobject.
    My javascript function - as shown in the code below - "ShowDutyWindowClient" fails when it tries to get the radwindowmanager. Radwindowmanger object returns null.
    I would appreciate help with this.

    Thanks,
    Manisha

    Here is my code
    //Usercontrol – codebehind
      
      
    protected void rgDuty_ItemCommand(object source, GridCommandEventArgs e)
       {
                switch (e.CommandName)
                {
                    case RadGrid.InitInsertCommandName:
                        e.Canceled =true;
                        long positionDescriptionID = CurrentPDID;
                        script = string.Format("ShowDutyWindowClient('{0}','{1}');", "Insert", positionDescriptionID);
        ScriptManager.RegisterStartupScript (this,this.GetType (),"showdutywindowClient" ,script,true  );
                        break;
                          
                  case RadGrid.EditCommandName :
                        e.Canceled = true;
                        gridItem = e.Item as GridDataItem;
                        int dutyID = int.Parse(gridItem.GetDataKeyValue("DutyID").ToString());
                        script = string.Format("ShowDutyWindowClient('{0}','{1}');", "Edit", dutyID);
         ScriptManager.RegisterStartupScript (this,this.GetType (),"showdutywindowClient" ,script,true  );
                        break; 
     default:
                        RGQualEnabled = true;
                        break;
                }
            }
    }
                  
      
    //UserControl Design 
    <telerik:RadWindowManager ID="radWindowManagerDuties" runat="server" Behavior="Default"
        InitialBehavior="None" RegisterWithScriptManager="true">
        <Windows>
            <telerik:RadWindow ID="rwPDDuties" runat="server" RegisterWithScriptManager="true" 
            Skin="WebBlue" Height="600" Width="600" Behaviors="Close" VisibleStatusbar="false"
            ReloadOnShow="true">
            </telerik:RadWindow>
        </Windows>    
    </telerik:RadWindowManager>
      
    <telerik:RadCodeBlock ID="rcbCodeBlock" runat="server">
    <script type="text/javascript">
     function ShowDutyWindowClient(mode, id) {
                var navigateurl;
                var title;
                 
                if (mode == "Insert") {
                    navigateurl = "~/CreatePD/AddEditDuty.aspx?mode=Insert&PositionDescriptionID=" + id;
                    title = "Add Duty";
                }
                else {
                    navigateurl = "~/CreatePD/AddEditDutyContent.aspx?mode=Update&DutyID=" + id;
                    title = "Edit Duty";
                }
      
                var oWnd = radopen(navigateurl, "rwPDDuties");
            }            
      
      </script>
      
    </telerik:RadCodeBlock>
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    4529 posts

    Posted 05 Mar 2012 Link to this post

    Hello Manisha,

    It seems you are performing a full postback from the grid, so the RadWindowManager is disposed as well, then your JavaScript is executed too early and it is not yet initialized. This happens in the Sys.Application.Load event as explained in the following article, which I recommend you examine on injecting a script from the code-behind: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html. Another option is to use AJAX - wrap the grid in an UpdatePanel so that it is the only part of the page that is disposed.


    Kind 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.
  3. Manisha Shivjiani
    Manisha Shivjiani avatar
    24 posts
    Member since:
    Nov 2009

    Posted 05 Mar 2012 Link to this post

    Hi,

    Thanks for the reply.
    Your solution worked. I ajaxified grid with radAjaxManager and called the Js function from serverside and it worked.

    Thanks,
    Manisha
Back to Top