아래 코드는 Asp.Net에서 yes no를 사용하여 확인 메시지 상자를 실행합니다.
그 값이 확증되었는지 아닌지를 알아 내야합니다.
어떻게하면됩니까?메시지 박스가 올바르게 작동하지 않는 것을 확인하십시오.
영문 :
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type = "text/javascript">
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Do you want to save data?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="btnConfirm" runat="server" OnClick = "OnConfirm" Text = "Raise Confirm" OnClientClick = "Confirm()"/>
</form>
</body>
</html>
코드 뒤에 :
protected void OnConfirm(object sender, EventArgs e)
{
// This method runs even though the user clicks no.
}
업데이트 :이 코드
, 모두 예 또는 아니오 선택은 OnConfirm 이름이 같은 방법으로 실행됩니다. 그래서 OnConfirm 메서드 only if the user clicks yes
을 실행 해 봅니다.
는 [내가 여기 해결책을 발견했다 (http://stackoverflow.com/a/9835475/1136253) –