Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A disabled checkbox can still be checked in C#

I have a check box in my page as follows:

  <asp:CheckBox ID="chkPayerCB" 
    runat="server" 
    Text="Payer Core Banking details" 
    TextAlign="Right"/>

I need to disable it on Page Load event of the page. I wrote the following code in code behind:

 chkPayerCB.Enabled = false;

Though the check box is disabled but it still gets checked for a moment on clicking at it and then gets unchecked. Though it solves my purpose but I do not want it to be checked at any cost.

I am using VS 2008 Professional Edition (v 9.0.2). Please can anybody guide me on this.

like image 756
Rishik Mani Avatar asked Oct 31 '22 03:10

Rishik Mani


1 Answers

You can use a different approach.

Set Enabled = False in the Designer.

If you need to enable it under some circustances you can use Page_Load event.

like image 179
tezzo Avatar answered Nov 09 '22 04:11

tezzo