試試這個方法:
語法
public void RegisterOnSubmitStatement (
Type type,
string key,
string script
)
使用
放置在頁面加載此代碼使腳本火的網絡表單提交的每點擊。
if (!script.IsClientScriptBlockRegistered(this.GetType(), "SubmitScript"))
{
script.RegisterOnSubmitStatement(this.GetType(), "SubmitScript", "alert('Submit Clicked')");
}
考慮下面的代碼
protected void Page_Load(object sender, EventArgs e)
{
ClientScriptManager script = Page.ClientScript;
if (!script.IsClientScriptBlockRegistered(this.GetType(), "SubmitScript"))
{
script.RegisterOnSubmitStatement(this.GetType(), "SubmitScript", "return confirm('Are you sure to continue')");
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
Response.Write("Form is Submitted.");
}
你到底想幹什麼?也許有其他的替代品 – MilkyWayJoe 2012-04-10 16:45:04