(实践证明,不论是否采用判断,都会弹出对话框。估计是页面发回服务器后,再发来,脚本就丢失了)可能在异步的时候有用

Posted 挣脱生命的束缚...

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(实践证明,不论是否采用判断,都会弹出对话框。估计是页面发回服务器后,再发来,脚本就丢失了)可能在异步的时候有用相关的知识,希望对你有一定的参考价值。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


    }

    //插入到文档的末端
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (!this.Page.ClientScript.IsStartupScriptRegistered("key1"))
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "key1", "<script language=javascript>alert(\'" + "ok1" + "\')</script>");
        }

    }

   //插入到文档的顶端(实践证明,不论是否采用判断,都会弹出对话框。估计是页面发回服务器后,再发来,脚本就丢失了)
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (!this.Page.ClientScript.IsClientScriptBlockRegistered("key2"))
        {
            this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "key2", "<script language=javascript>alert(\'" + "ok2" + "\')</script>");
        }
    }
}

 

以上是关于(实践证明,不论是否采用判断,都会弹出对话框。估计是页面发回服务器后,再发来,脚本就丢失了)可能在异步的时候有用的主要内容,如果未能解决你的问题,请参考以下文章