先运行js。或者先运行Click事件,近期就遇到了这个问题,開始弄了两个button分别运行,那才叫一个蛋疼...

1.先运行js,再运行Button的Click函数


前台js为



在后台Page_Load()里加上

protected void Page_Load(object sender, EventArgs e)
{          
   if (!Page.IsPostBack)
   {
      btn_delete.Attributes.Add("OnClick", "return  xxx()");
   }
}

2.先运行Button的click事件,在运行js

    protected void btn_delete_Click(object sender, EventArgs e)
    {
        ClientScript.RegisterStartupScript(Page.GetType(), "", "xxx()", true);
    }

相关文章: