Welcome to AspAdvice Sign in | Join | Help

AzamSharp

Some day I will know everything I hope that day never comes

Syndication

Tags

Navigation

Input CheckBox Checked Property

INPUT checkbox checked property is kind of funny. This is because the name of the property also becomes the value of the property as shown in the example below:

input type="checkbox" checked = "checked"

or simply

input type="checkbox" checked

So, if you want to dynamically generate the checkbox at runtime and not make the checkbox checked then simply remove the checked property as shown below:

bool showChecked = true;

Literal lit = new Literal();

lit.Text = "<input type=\"checkbox\" " + (showChecked == true ? "Checked" : String.Empty) +"/>" ;

this.pn1.Controls.Add(lit);

this.pn1.DataBind();

In my opinion the checked property should have boolean value. So, we can say something like the following:

<input type=checkbox checked = true/false />

:)

Sponsor

Published Saturday, October 27, 2007 11:22 AM by azamsharp

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required) 
Enter the code you see below