How to display checkboxes on a read-only form (ASP.NET)

I have a read form filled out automatically from a database. I have several fields with true / false values, and they would like them to appear as checkboxes that are either empty or checked. I can bind the checkbox control and disable it, but then it looks gray. Is there an easy way to change this so that it appears with normal, easy-to-read courage, but is still disabled? If not, what is the best way to do this? Should I use an image?

+3
source share
4 answers

Interest Ask!

, , , ( ) . , , , , .:)

jQuery ( Chrome IE 9, ).

$('.readonly:checkbox').click(function(e) {
    e.preventDefault();
});

"" "readonly".

JavaScript (albiet , ):

<input type="checkbox" onclick="event.preventDefault();" />

, "preventDefault()" "return false", , false . , . ... .

, Bala R, . , .

jsFiddle: http://jsfiddle.net/xixionia/3rXCB/

, !:)

+3

.

<asp:CheckBox id="checkbox1" Text="Custom" onclick="javascript: return false;" />

<input type="checkbox"
checked  onclick="javascript: return false;">Custom</input>
+6

- javascript checkbox onclick handler.

jsFiddle

function makeMeReadonly(checkbox){
    checkbox.checked = !checkbox.checked;
}

<asp:CheckBox id="checkbox1" onclick="makeMeReadonly(this)" />

<asp:CheckBox id="checkbox1" onclick="this.checked = !this.checked" />

.

, , javascript / , , , - .

+1

, OnClick. .Checked , .

private void chkBox_CheckStateChanged(object sender, EventArgs e)
    {
        chkBox.Checked = boolDatabasevalue;
        return;
    }

, , .

- , . , OP, - .

NB: #, Asp.Net .

+1

All Articles