//=================================
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace HuaNengOA
{
/// <summary>
/// test 的摘要说明。
/// </summary>
public class test : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
you can't do as you think,because the script is execute at client but the C# code execute at server,client and server can comunicate only while submit the form to server at client;
but the is a method fit to you:
Button myButton;
private void Page_Load(object sender,EventArgs e)
{
myButton.Attributes.Add("onclick","return if(confirm('修改成功?')){return true;}");
}
so if you client "确定",the client submit the form to server to execute the method you defined(just as your method
private void myButton_Click(Object sender,EventArgs e){
}
)
or it will not submit the form and do nothing