ClientScript.RegisterStartupScript not working

前端 未结 2 499
不知归路
不知归路 2021-01-18 06:50

I have searched SO & google, but I can\'t seem to get this to work. The code is in the codebehind click event of a \"Cancel\" button in my asp.net application but does

相关标签:
2条回答
  • 2021-01-18 07:15

    You can use this instead

    ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup", "window.close();", true);
    

    or you can also try this one

    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "ClosePopup", "window.close();", true);
    

    Have a Good day.

    0 讨论(0)
  • 2021-01-18 07:27

    since I could not get the ClientScript to work as required, I did a workaround using the code below:

        function closeWin() {
            //If txt = 'cancel' then close;
            GetRadWindow().Close();
        }
    
    
    <td align="center"><asp:Button runat="server" ID="btnClose" Text="Close" 
            OnClientClick="closeWin();return false;" onclick="btnClose_Click"/></td>
    
    0 讨论(0)
提交回复
热议问题