In running a webserver with a basic form where I store the input values from the different fields on submit, but I can't seem to get it right with checkboxes.
I wan't to store the state of the checkbox - something along the lines of this code:
if (ifttt_active.IsChecked)
{
// Do something
} else {
// Do someting else
}
But is that even possible? Or do we need some kind of "ninjatricks" to get it working?
Thanks
With a checkbox, the GET or POST request sends not value at all if the box is not checked, and sends a value ('on', I think, or maybe the value) if it is checked.
So if your form has a name, othername, and checkbox 'ok', then the incoming request
GET /myform?name=foo&othername=bar HTTP/1.1
means 'ok' was not checked and the incoming request
The below site might have some info for you. Note that if someone else accesses the server and changes whatever is being controlled, your check box will no longer represent the current status of the device.