如何在.cs中使用JavaScript刷新父页面 [英] How to refresh parent page using javascript in .cs

查看:41
本文介绍了如何在.cs中使用JavaScript刷新父页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



关闭弹出窗口(子窗口)时如何刷新父窗口.

我们正在通过使用page.ClientScript.RegisterStartupScript()在后面的代码中调用Java脚本函数来刷新父窗口.但是t在IE(互联网浏览器)中工作正常,但在Mozilla Firefox和Google Chrome中无法正常工作.

在Mozilla Firefox中,弹出值保存在数据库中,但没有更新到父页面中.如果我确实手动刷新,则该值将更新到父页面中.如果我将调试器放在IE的RefreshPage()(javascript函数)函数中,则它会触发,但在Firefox中不会.

以下代码用于在.cs类中调用javascript函数.

Hi,

How to refresh the parent window while closing the popup window(child window).

We are calling the java script functions in code behind to refresh the parent window by using page.ClientScript.RegisterStartupScript().But t is working fine in IE(internet explorer) but not working in Mozilla Firefox and Google Chrome.

In the Mozilla Firefox the pop up value is saving in the database but it is not updating into the parent page.If i did refresh manually the value is getting updating into the parent page. If i put debugger in RefreshPage()(javascript function) function in IE it is firing but not in Firefox.

The below code for call the javascript function in .cs class.

page.ClientScript.RegisterStartupScript(this.GetType(), "PopupSave", "<script>javascript:alert('" + dsMessage.Tables[0].Rows[0]["ErrorMessage"].ToString() + "');window.open('','_self','');window.close();window.document.forms[0].submit();</script>");



上面的代码RefreshPage()是刷新页面的javascript函数




The above code RefreshPage() is the javascript function to refresh the page

i.e.

function RefreshPage() { window.document.forms[0].submit(); } 



请帮助我,我尝试了不同的情况,但是没有输出.

而不是RefreshPage()我使用了不同的功能

像reload(),

window.opener.forms [0] .submit(),

同样,但仍然没有任何人知道的输出,请帮助我.



Please help me i tried with different scenarios but no output.

instead of RefreshPage() i used different functions

like reload(),

window.opener.forms[0].submit(),

likewise but still no output anyone knows please help me.

推荐答案

将页面呈现给客户端后,您只有两种方式可以强制刷新.一种是Javascript

setTimeout("location.reload(true);",超时);

第二个是元标记:

< meta http-equiv =刷新" content ="600"/>

您可以在服务器端设置刷新间隔.
Once the page is rendered to the client you have only two ways of forcing a refresh. One is Javascript

setTimeout("location.reload(true);", timeout);

The second is a Meta tag:

<meta http-equiv="refresh" content="600"/>

You can set the refresh intervals on the server side.


这篇关于如何在.cs中使用JavaScript刷新父页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆