我有一个按钮,当点击它时,我必须生成一个带有“确定”“取消”按钮的警报框。我已经这样做了,.aspx 上的脚本是,
<script>
function getConfirmationValue2()
{var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value2";
if (confirm("Save??")) {
confirm_value.value = "OK";
} else {
confirm_value.value = "CANCEL";
}
document.forms[0].appendChild(confirm_value);
} </script>
<asp:ImageButton ID="btn_submit" runat="server" ImageUrl="~/images/BtnSubmit.png" CausesValidation="true"
onclick="btn_submit_click"/>
单击按钮时,
protected void btn_submit_click(object sender, ImageClickEventArgs e)
{
if(TextBox1.Text="start")
{
btn_submit.OnClientClick = @"return getConfirmationValue2();";
string confirmValue122 = Request.Form["confirm_value2"];
if (confirmValue122 == "OK")
{
//updating the datas
}
}}}
它仅在单击按钮两次时才会生成警报框。会有什么问题?