禁用复选框,JavaScript和承认它在服务器端作为托运 [英] Disable a checkbox in javascript and recognize it as checked on the server side

查看:101
本文介绍了禁用复选框,JavaScript和承认它在服务器端作为托运的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某些情况下可能会被禁用一个复选框,并使用JavaScript选中,即:

I have a checkbox which in some cases may be disabled and checked using javascript, i.e:

var cbTest = document.getElementById("CheckBoxTest");
cbTest.disabled = true;
cbTest.checked = true;

然而,发送回发时, CheckBoxTest.Checked 是在服务器端错误的。

时可以禁用的复选框,仍然有服务器端将其识别为检查?

Is it possible to disable the checkbox and still have the server side recognize it as checked?

推荐答案

表格内的任何禁用的控件将不会提交到服务器上后回来。您可以添加一个隐藏的输入控制,并把该复选框状态,输入和服务器端的检查隐藏的输入值。

Any disabled control inside a form will not submitted to server on post back. You can add a hidden input control and put the checkbox state to that input and server side check that hidden input value.

这篇关于禁用复选框,JavaScript和承认它在服务器端作为托运的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆