adding attribute to checkbox

  • Thread starter Thread starter BK Kim
  • Start date Start date
B

BK Kim

hello.

I am trying to add an attribute on the checkbox.

In my C# code,

chkText.Attributes.Add("onChange", "window.alert('hello');return false");

But the result is like below on the web browser,

<span onChange="window.alert('bk');return false"><input id="chkTest"
type="checkbox" name="chkTest" /><label for="chkTest">test</label></span>

Anyone know how to add that onChange event on the input tag???

Thanx in advance
 
BK Kim said:
hello.

I am trying to add an attribute on the checkbox.

In my C# code,

chkText.Attributes.Add("onChange", "window.alert('hello');return false");

But the result is like below on the web browser,

<span onChange="window.alert('bk');return false"><input id="chkTest"
type="checkbox" name="chkTest" /><label for="chkTest">test</label></span>

Anyone know how to add that onChange event on the input tag???

You can't. The CheckBox control is the span, not the input tag.

You'll have to use <input type="checkbox" runat="server"> instead.
 
Back
Top