@ Html.TextBox(" SomeID"," SomeValue",new {type =" Checkbox"}}) [英] @Html.TextBox("SomeID", "SomeValue" ,new { type = "Checkbox" })
问题描述
我已经在视图页面上使用asp.net mvc 4中的文本框创建了一个复选框。
@ Html.TextBox(SomeID,SomeValue ,新{type =Checkbox})
现在基于某些条件,我想选中此复选框。
怎么可能呢?
我试过@ Html.TextBox(SomeID,SomeValue,new {type =Checkbox ,value =true})
但它不起作用。
谢谢。
您应该将 AllowRating 属性设置为true,最好是在控制器或模型中。
和其他人一样输入,复选框的状态反映了属性的值。
使用javaScript / jquery你可以选中/取消选中复选框
< script type = text / javascript>
if ( // 这里检查你的条件)
{
( #SomeID )。attr(' 选中',真跨度>);
}
< / script>
OR
@ Html.TextBox(SomeID,someValue,new {type =Checkbox,@ checked = true} )
I have created a checkbox using textbox in asp.net mvc 4 on view page like this.
@Html.TextBox("SomeID", "SomeValue" ,new { type = "Checkbox" })
now based on some condition, I would like to check this checkbox.
How could it be possible?
I have tried @Html.TextBox("SomeID", "SomeValue" ,new { type = "Checkbox", value = "true" })
but it is not working.
Thank you.
You should set the AllowRating property to true, preferably in the controller or model.
Like other inputs, the checkbox's state reflects the value of the property.
by using javaScript/jquery you can Check/Uncheck the checkBox
<script type="text/javascript"> if (//Here Check your Condition) {
("#SomeID").attr('checked', true); }
</script>
OR
@Html.TextBox("SomeID", "someValue" ,new { type = "Checkbox",@checked=true })
这篇关于@ Html.TextBox(" SomeID"," SomeValue",new {type =" Checkbox"}})的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!