In my main "Report" page, there are actions available to the user that open a modal RadWindow. The user can then take actions within the modal window, click Save, and the modal window should close while the main grid refreshes.
While this functionality works well in both IE and Firefox, Chrome seems to be causing an issue. In Chrome, all the actions are performed correctly, but the modal page remains open after clicking Save. Interestingly, the Cancel button and the close button on the form still work as expected.
The JavaScript code in the child window is as follows:
<script type="text/javascript">
function GetRadWindow() {
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
return oWindow;
}
function CloseRadWindow() {
var oWnd = GetRadWindow()
oWnd.SetUrl("");
oWnd.close();
}
function CloseAndRebind(args) {
var oWnd = GetRadWindow()
oWnd.BrowserWindow.refreshGrid(args);
oWnd.SetUrl("");
oWnd.close();
}
</script>
The parent's refreshgrid function is as follows:
<script type="text/javascript">
function refreshGrid(arg) {
if (!arg) {
$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("Rebind");
}
else {
$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("RebindAndNavigate");
}
}
</script>
The modal window on the parent page is triggered by the button click event:
protected void btnSplitInvoice_Click(object sender, EventArgs e)
{
var btn = sender as Button;
var item = (GridDataItem)btn.Parent.Parent;
long id = long.Parse(item["Id"].Text);
var itemType = this.TabStrip1.SelectedIndex == 0 ? "TransferOrderInvoice" : "EquipmentInvoice";
string scriptstring = "var oWindow=radopen('../Misc/SplitInvoice.aspx?id=" + id + "&type=" + itemType + "','SplitInvoice');oWindow.SetModal(true);";
ScriptManager.RegisterStartupScript(this, this.GetType(), "openwindow", scriptstring, true);
}
After performing the necessary operations in the code behind, the child window's save button is handled with:
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "mykey", "CloseAndRebind('navigateToInserted');", true);
The cancel button is set up as follows:
<button type="button" class="CancelBtn" value="" onclick="CloseRadWindow()">
</button>
When encountering issues in Chrome, it was suggested to add window.open('', '_self', '');
to the close, but this did not resolve the problem. After investigating in the Chrome console, an error was noticed on the main page when refreshgrid
is executed:
Cannot call method 'ajaxRequest' of null
Further investigation revealed that Chrome does not seem to find the RadAjaxManager from the Master page in time for refreshGrid
to run, thus resulting in the null error mentioned above. A temporary solution was implemented by replacing the contents of the refreshGrid function with document.location.reload();
which works, but reloading the entire page is not ideal. The reason for this discrepancy between Chrome and IE/Firefox is not clear.
Additional information that may be helpful includes the Page_Load event in the main page:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.Session["AllUserLocationValue"] = string.Empty;
this.InitializeThePage();
}
RadAjaxManager manager = RadAjaxManager.GetCurrent(this.Page);
manager.AjaxRequest += this.manager_AjaxRequest;
manager.AjaxSettings.AddAjaxSetting(manager, this.pnlHeading, this.RadAjaxLoadingPanel1);
manager.AjaxSettings.AddAjaxSetting(manager, this.RadCodeBlock1, this.RadAjaxLoadingPanel1);
}