开发者

JavaScript function is not working

开发者 https://www.devze.com 2023-03-09 14:51 出处:网络
I have this line in a button click method on my aspx.cs file ClientScript.RegisterStartupScript(this.GetType(),

I have this line in a button click method on my aspx.cs file

ClientScript.RegisterStartupScript(this.GetType(), 
                                   "RefreshOpener", 
                                   "RefreshParent()", 
                                    true);

I have this code on aspx file

function RefreshParent() {              
                   window.opener.location.href = window.opener.location.href;

        } 

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 ha开发者_StackOverflowve used the same things on some other pages with the same methods and they worked but this time it is not.

This is the button mentioned

<asp:ImageButton ID="Button_KAYDET" 
                 runat="server" 
                 CausesValidation="False"
                 ImageUrl="~/images/butonlar/kucuk/kaydet.jpg"
                 OnClick="Button_KAYDET_Click"
                 meta:resourcekey="Button_KAYDETResource1" />

Any ideas?


If the button is placed inside of an UpdatePanel then you'll need to use the ScriptManager.RegisterStartupScript method (MSDN Link).

Your code should look like:

ScriptManager.RegisterStartupScript(this, this.GetType(), "RefreshOpener","RefreshParent()", true);


Does the Button_KAYDET button placed in an UpdatePanel? if it is use the ScriptManager.RegisterStartupScript method instead of the ClientScript.RegisterStartupScript

0

精彩评论

暂无评论...
验证码 换一张
取 消