JavaScript函数不工作 [英] JavaScript function is not working
问题描述
我此行的一个按钮点击的方法对我的aspx.cs文件
I have this line in a button click method on my aspx.cs file
ClientScript.RegisterStartupScript(this.GetType(),
"RefreshOpener",
"RefreshParent()",
true);
我对aspx文件这个code
I have this code on aspx file
function RefreshParent() {
window.opener.location.href = window.opener.location.href;
}
当我第调试code,谈到此行 ClientScript.RegisterStartupScript(this.GetType()
,但不会去aspx文件运行JS code。
RefreshOpener
RefreshParent(),
真正);
When I debug th code, it comes to this line ClientScript.RegisterStartupScript(this.GetType(),
"RefreshOpener",
"RefreshParent()",
true);
but does not go to aspx file to run the JS code.
最令人沮丧的是我已经使用了一些其他页面同样的事情用相同的方法和他们的工作,但这次不是。
The most frustrating part is I have used the same things on some other pages with the same methods and they worked but this time it is not.
这是中提到的按钮
<asp:ImageButton ID="Button_KAYDET"
runat="server"
CausesValidation="False"
ImageUrl="~/images/butonlar/kucuk/kaydet.jpg"
OnClick="Button_KAYDET_Click"
meta:resourcekey="Button_KAYDETResource1" />
任何想法?
推荐答案
如果该按钮被放在一个UpdatePanel里面,那么你就需要使用ScriptManager.RegisterStartupScript方法(<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerstartupscript.aspx\"相对=nofollow> MSDN链接)。
If the button is placed inside of an UpdatePanel then you'll need to use the ScriptManager.RegisterStartupScript method (MSDN Link).
您code应该是这样的:
Your code should look like:
ScriptManager.RegisterStartupScript(this, this.GetType(), "RefreshOpener","RefreshParent()", true);
这篇关于JavaScript函数不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!