Void按钮收到true后有一个确认框,期待运行另一个按钮的点击事件 但是,Void2_Button_Click没有运行,哪里出错了?
protected void Void2_Button_Click(object sender, EventArgs e)
{
// do something
}
Void_Button.Attributes.Add("onclick", "var agree=confirm('Confirm to void?'); if (agree){document.getElementById('Void2_Button').click();}");
这个问题还没有解决,谁能回答?
答案 0 :(得分:2)
您也可以让普通服务器端单击第一个按钮,只需调用另一个按钮的click事件:
<asp:Button id="Void_Button" runat="server" Text="Void" OnClick="Void_Button_Click" OnClientClick="return confirm('Confirm to void?');" />
protected void Void_Button_Click(object sender, EventArgs e)
{
Void2_Button_Click(sender, e)
}
答案 1 :(得分:1)
您必须将.ClientID用于javascript。尝试
Void_Button.Attributes.Add("onclick", "var agree=confirm('Confirm to void?'); if (agree){document.getElementById('"+Void2_Button.ClientID+"').click();}");