我希望能够在checkbox单击asp.net 时显示确认消息,我尝试使用:
OnClientClick = "return confirm('Are you sure you want to logout?')"
Run Code Online (Sandbox Code Playgroud)
它不报告错误,但不工作,我后来发现 asp.net 复选框没有OnClientClick属性。
我也在google上做了一些研究还是没能实现!请问有人知道怎么做吗?提前致谢。
经过大量研究,我能够实现这一点,这是答案,因此面临相同问题的其他用户可以使用它:
OnClick="if(!confirm('Are you sure you want to sign out?'))return false;" 这对我来说非常有效。
你可以看这里
您可以使用 javascript 通过选中count复选框来做到这一点。
像下面这样
if (chkCount === 0) {
alert("You do not have any selected files to delete.");
return false;
} else {
return confirm("Are you sure you want to proceed deleting the selected files?");
}
Run Code Online (Sandbox Code Playgroud)
希望有帮助