I have an asp:checkbox
with OnClick="return false"
which 'closes' it for changes (that's the nearest equivalent to ReadOnly=true
which I found).
I also have a button.
When I click the button I need the codebehind (C#) to change the checkbox to "return true", that is : to 'open' it for checking or unchecking. Clicking the button again should 'close' it back again.
In short - how do I toggle between these two states in the code behind?
HTML:
<asp:Button runat="server" ID="my_Button" Text="click me" OnClick="my_Button_Click" />
<asp:CheckBox runat="server" ID="my_CheckBox" Checked="true" OnClick="return false;" />
Code behind:
protected void my_Button_Click(object sender, EventArgs e)
{
// here is where the toggling should come... <============
}