HTML.CheckboxFor在发布操作时没有获得值 [英] HTML.CheckboxFor doesn't get value when post action

查看:80
本文介绍了HTML.CheckboxFor在发布操作时没有获得值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在构建一个Web应用程序,我在HTML.Helper和命名字段IsSpecial中使用HTML.CheckboxFor并允许null。

当我选中复选框时,它没有获得复选框控件的值,我调试并且我看到它的值(IsSpecial)= null。



如何我能做什么?

非常感谢大家。

hi everyone,

I'm building a web app and i use HTML.CheckboxFor in HTML.Helper and named field IsSpecial and allow null.
When I checked on checkbox, it did not get value of checkbox control, I debug and I see its value (IsSpecial) = null.

How can I do ?
Thank everyone very much.

推荐答案

通常如果取消选中复选框,控件不会传入html,所以你必须验证服务器端脚本中的一个
normally if checkbox is unchecked that control does not pass in html so you have to validate that one inside your server side script


如果你要使用php,你可以这样验证。



if you going to use php you can validate like this.

if(isset(


_POST [' vtype'])){
// 做你想做的事
}
_POST['vtype'])){ //do what you want to do }


这篇关于HTML.CheckboxFor在发布操作时没有获得值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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