asp.net页面中弹出对话框 选择“确定”后实现事件回调
方法一:
protected void Button2_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "startDate", "<script language='javascript'>if (confirm('确认这样操作?')){document.getElementById('" + this.Button1.ClientID + "').click();} ; </script>");
}
Button1为隐藏的“客户端”button,设置runat="server"
在Button1的事件里可以写我们想要的事情。
方法二:
/// <summary>
/// 实现回调
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button2_Click(object sender, EventArgs e)
{
//ClientScript.RegisterStartupScript(this.GetType(), "sss", "<script>if(confirm('确认这样操作?')){onclick=__doPostBack('Button1','');}</script>");
ClientScript.RegisterStartupScript(this.GetType(), "startDate", "<script language='javascript'>if (confirm('ok?')){document.getElementById('" + this.Button1.ClientID + "').click();} ; </script>");
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("我要创建");
}