asp.net - set unchecked value of checkbox -
is there way of setting default unchecked value of checkbox? not using databound control. passing data form , pass false opposed null when unchecked.
yes, using default htmlhelpers
achieve you
<%: html.checkbox("mycheckbox") %>
or razor
@html.checkbox("mycheckbox")
the checkbox()
method render input type="hidden"
field along side input type="checkbox"
submit value false
when checkbox unchecked.
<input id="mycheckbox" name="mycheckbox" type="checkbox" value="true" /> <input name="mycheckbox" type="hidden" value="false" />
if want submit value other false
should render checkbox , hidden field setting value of hidden field default value. note must have same name attribute.
Comments
Post a Comment