我正在使用 MVC 3 并且我有一个复选框:@Html.CheckBox("mycheckbox", myparam)
我想在选中/取消选中复选框时刷新页面。 我该怎么做?
最佳答案
为此您需要使用 javascript。例如,您可以为复选框分配一个唯一的 ID(或类):
@Html.CheckBox("mycheckbox", myparam, new { id = "mycheck" })
然后使用 jQuery 订阅 .change()
事件:
$(function() {
$('#mycheck').change(function() {
// the value of the checkbox changed => refresh the page:
window.location.reload();
});
});
关于c# - 复选框事件重新加载页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8066344/