D
darkpeace
Okay i'm at my wits end. I've tried every which way to add a simple
onClick even to checkbox items in my code behind :
example:
Protected WithEvents chkSample As
System.Web.UI.WebControls.CheckBoxList
....
For Loop i = 0; i++ here
Dim item As ListItem = New ListItem
item.text = "Checkbox 1"
item.value = "1"
'method 1 - Indirect Add of Attribute
item.Attributes.Add("OnClick", "alert('hello world')")
'method 2 - Direct Add of Attribute
chkSample.Items(i).Attributes("onClick") = "javascript:alert('hello')
End Loop
....
In HTML, and in both cases I see this:
<input id="_ctl0__ctl3__ctl0_chkSample_1" type="checkbox"
name="_ctl0:_ctl3:_ctl0:chkSample:1" />
I want to see this:
<input id="_ctl0__ctl3__ctl0_chkSample_1" type="checkbox"
name="_ctl0:_ctl3:_ctl0:chkSample:1" onClick="alert('hello')"/>
No Build errors on either method.. I know i can setup a individual
check box use the attributes.add() and then use the controls.Add() to
place the code in the relevant area. However that shouldn't be
necessary? Any ideas?
I think this may be related to the following thread as a bug?
http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=430387
onClick even to checkbox items in my code behind :
example:
Protected WithEvents chkSample As
System.Web.UI.WebControls.CheckBoxList
....
For Loop i = 0; i++ here
Dim item As ListItem = New ListItem
item.text = "Checkbox 1"
item.value = "1"
'method 1 - Indirect Add of Attribute
item.Attributes.Add("OnClick", "alert('hello world')")
'method 2 - Direct Add of Attribute
chkSample.Items(i).Attributes("onClick") = "javascript:alert('hello')
End Loop
....
In HTML, and in both cases I see this:
<input id="_ctl0__ctl3__ctl0_chkSample_1" type="checkbox"
name="_ctl0:_ctl3:_ctl0:chkSample:1" />
I want to see this:
<input id="_ctl0__ctl3__ctl0_chkSample_1" type="checkbox"
name="_ctl0:_ctl3:_ctl0:chkSample:1" onClick="alert('hello')"/>
No Build errors on either method.. I know i can setup a individual
check box use the attributes.add() and then use the controls.Add() to
place the code in the relevant area. However that shouldn't be
necessary? Any ideas?
I think this may be related to the following thread as a bug?
http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=430387