Link to home
Start Free TrialLog in
Avatar of jackjohnson44
jackjohnson44

asked on

checkbox .net prevent from changing state based on condition

how can I put code in a checkbox event that calls another function, if it returns a false, prevent the checkbox from changing state?

checkbox_onclick()
   if (somefunction) then
       checkbox.checked = state before it was just clicked
   end if
Avatar of kerryw60
kerryw60

You could save the state of the checkbox in a variable before you test your function

Dim myState as Boolean = checkboxvalue

if somefunction then
   checkbox.checked = mystate
end if
Avatar of Bob Learned
And, you didn't want to disable the CheckBox?

Bob
ASKER CERTIFIED SOLUTION
Avatar of kerryw60
kerryw60

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you could create a Session variable and set it before checkbox click event is called:

Session("status")=checkbox.checked

checkbox_onclick()
   if (somefunction) then
       checkbox.checked = Session("status")
   end if