且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在C#Asp.net中注销Page.ClientScript

更新时间:2023-12-05 23:20:34

您可以将空字符串分配给同一键radalert以删除脚本.

You can assign empty string to same key radalert to remove the script.

if(some_condition)
    Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", "");

编辑:基于注释,您可以简化操作,而无需使用RegisterStartupScript

Based on comments, you can make it simple without using RegisterStartupScript

在后面的代码中

btnSave.Attributes.Add("", "saveButtonFunction();");

用Java语言

<script language='javascript'>

   Sys.Application.add_load(function(sender, e) {
           if(btnSaveClicked){
              var oWnd = radalert('dialogMessage', 400,140, 'Saved');
              window.setTimeout(function () { oWnd.Close(); }, 3000);
              btnSaveClicked = false;
           }
    });

    btnSaveClicked = false;
    function saveButtonFunction(){
       btnSaveClicked = true;
    };    

</script>