0
<input type="checkbox" name="chkbox" 
 onclick="Utility('<%# Eval("id") %>');"
checked='<%# Eval("Contacted") %> ' />

onclick is used to run AJAX, which updates the record in the DB depending on wether the checkbox was selected or unselected.

My Q being....I want to grab 'T' or 'F' which is stored in 'contacted' in code behind I was trying to do this through the normal binding Eval("Contacted")...(as in code behind 'Contacted' will have the value.

Any ideas? thanks

John
  • 3,965
  • 21
  • 77
  • 163

2 Answers2

1

You can grab the value of checked (true or false) with:

var isChecked = $("#chkbox").is(":checked"); //returns true or false

You can set the value with prop

$("#chkbox").prop("checked", true); //Sets box to checked.
tymeJV
  • 103,943
  • 14
  • 161
  • 157
1

I believe what you want to achive is something like this:

<input type="checkbox" name="chkbox" id="chkbox" />

    $('#chkbox').change(function(e) {
        if($(this).is(':checked')) {
            // do whatever
        }
        else{
            // do whatever
        }
    });

xtyp
  • 49
  • 7