我有一个主要的“报告”页面,有一些用户可以采取的行动,将打开模态RadWindow,让用户采取行动,然后单击保存,模式窗口将关闭,主要网格刷新。莫代尔RadWindow在Chrome中不关闭
在IE和Firefox中均可正常工作,但Chrome会执行所有“工作”,但模态页面保持打开状态。这只有当我点击保存按钮时才是真的;窗体顶部的取消按钮和关闭按钮仍可正常工作。
这是从子窗口中的JavaScript:
<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>
这是父母的refreshgrid功能:
<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>
家长通过运行加载模态窗口:
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);
}
孩子的保存按钮在后面的代码中完成了大量的工作,然后完成:
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "mykey", "CloseAndRebind('navigateToInserted');", true);
取消按钮被设置为这样:
<button type="button" class="CancelBtn" value="" onclick="CloseRadWindow()">
</button>
我发现从一段时间回来,暗示将window.open('', '_self', '');
到接近一个条目,但似乎并没有适用的(也没当我测试它的时候,它不工作)。
编辑:当控制台打开安装Chrome,我看到我的主网页上得到一个错误,当refreshgrid
运行:
Cannot call method 'ajaxRequest' of null
但不知道这是什么引起的问题与否。现在看更多。
编辑2:所以这个问题似乎是,当使用Chrome浏览器时,主页面上的RadAjaxManager似乎没有被refreshGrid
运行时发现,这就是上述空错误的原因。我可以通过用document.location.reload();
代替refreshGrid函数的内核来“解决”这个问题,它确实很好。但是,如果我能够帮助它,我宁愿不重新加载整个页面,但是,想知道是否还有办法解决这个问题。而且我很好奇,为什么IE浏览器和Firefox似乎在Chrome浏览器不支持时处理这个问题?
更多的信息,可能是有用的:主要页面的Page_Load事件:
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);
}
感谢您的建议re:'SetUrl(“”)';它在这种情况下并没有影响到这个问题,但是根据你的解释我可以看到不使用它的价值。这个问题似乎是在refreshGrid中的$ find找不到母版页的RadAjaxManager的ClientId,尽我所知。 – 2013-03-26 17:59:38
这很奇怪。尝试制作一个单独的函数,它将返回此引用并确保其脚本标记不是任何部分回发的一部分;或一个全局的JS变量,它将保存管理器的CLIentID,所以你可以很容易地调试它以获得所需的ID。 您也可以使用简单的__doPostBack()或隐藏按钮并单击()。 – rdmptn 2013-03-27 08:19:21