This is a migrated thread and some comments may be shown as answers.
unable to locate radwindow object from radgrid_itemcommand event
2 Answers 17 Views
This is a migrated thread and some comments may be shown as answers.
Manisha Shivjiani
Top achievements
Rank 1
Manisha Shivjiani asked on 01 Mar 2012, 05:20 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 05 Mar 2012, 12:01 PM
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.
0
Manisha Shivjiani
Top achievements
Rank 1
answered on 05 Mar 2012, 06:24 PM
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
Asked by
Manisha Shivjiani
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Manisha Shivjiani
Top achievements
Rank 1
Share this question
or