Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 灰盒关闭后刷新父页面_Javascript_Asp.net_Greybox - Fatal编程技术网

Javascript 灰盒关闭后刷新父页面

Javascript 灰盒关闭后刷新父页面,javascript,asp.net,greybox,Javascript,Asp.net,Greybox,首先,祝大家圣诞快乐:) 我有一个博客,人们可以在那里发表评论。我现在决定将“writecomments.aspx”文件放在一个灰盒弹出窗口中。它可以工作,但是我想在写完注释后从codebehind(或javascript)关闭窗口。然后我想刷新博客页面(父页面)以显示新的评论 这是打开greybox(writecomments.aspx)页面的代码: 现在,Greybox正在关闭,然后博客页面正在刷新,就像我想要的:)一旦评论成功保存到DB,在页面中呈现以下javascript: window

首先,祝大家圣诞快乐:)

我有一个博客,人们可以在那里发表评论。我现在决定将“writecomments.aspx”文件放在一个灰盒弹出窗口中。它可以工作,但是我想在写完注释后从codebehind(或javascript)关闭窗口。然后我想刷新博客页面(父页面)以显示新的评论

这是打开greybox(writecomments.aspx)页面的代码:


现在,Greybox正在关闭,然后博客页面正在刷新,就像我想要的:)

一旦评论成功保存到DB,在页面中呈现以下javascript:

window.opener.reload();
window.close();
保存成功后,在WriteComments.aspx.cs中添加以下代码以在HTML中呈现javascript:

if (!IsClientScriptBlockRegistered("CloseMe"))
{
        String cstext1 = "<script type=\"text/javascript\">" +
            "window.opener.refresh(); window.close();</" + "script>";
        RegisterStartupScript("CloseMe", cstext1 );
}
如果(!IsClientScriptBlockRegistered(“CloseMe”))
{
字符串cstext1=“”+
“window.opener.refresh();window.close();”;
RegisterStartupScript(“CloseMe”,cstext1);
}

我让关闭功能工作了!这是我必须使用的代码:Page.ClientScript.RegisterStartupScript(This.GetType(),“close”,“parent.parent.GB_hide();”,true);现在,我只需要以某种方式刷新父页面:)

因为我正在寻找类似的行为,这在我的情况下是有效的:

“请浏览此文件(gb_scripts.js) 第12行 将“this.reload\u on\u close=false;”更改为“this.reload\u on\u close=true” 和67号线 将“window.location.reload();”更改为“window.location.reload(true);” 完成了
«最后一次编辑:2010年12月20日04:38:42上午shashidharkumar»“

以下是解释清楚的答案,步骤简单:

谢谢!但是我是javascript的新手。在成功插入db之后,我如何从codebehind“运行”这个呢?用一个示例更新了上一篇文章。谢谢!但是现在,当点击save按钮时,它只是在按钮旁边写上文本“CloseMe”..My bad,早些时候交换了参数,请尝试更新的参数。在Chrome控制台中,它显示:Uncaught TypeError:无法调用null(匿名函数)的'reload'方法。
window.opener.reload();
window.close();
if (!IsClientScriptBlockRegistered("CloseMe"))
{
        String cstext1 = "<script type=\"text/javascript\">" +
            "window.opener.refresh(); window.close();</" + "script>";
        RegisterStartupScript("CloseMe", cstext1 );
}