Registerd Client Script Not Working

  • Thread starter Thread starter Red
  • Start date Start date
R

Red

I am trying to call some java script from an ASP:Checkbox control.

My code is as follows:
Dim PilotCheckScript As String = "<script language=javascript >" & vbCrLf &
_

"function PilotCheckChanged(){" & vbCrLf & "alert(""Check Changed!"");" &
vbCrLf & _

"txtPILOT.Enabled = !chkPILOT.Checked;" & vbCrLf & "}" _

& vbCrLf & "</script>"

Me.Page.RegisterClientScriptBlock("PilotCheckChangedScript",
PilotCheckScript)

Me.chkPilot.Attributes("OnCheckChanged") = "JavaScript:PilotCheckChanged();"



The code compiles fine and the web form comes up but nothing happens when
the OnCheckChanged event is fired.



Any help is greatly appreciated.



TIA.
 
I actually modified the code I realized I was should hae been using
OnCheckedChanged not OnCheckChanged, however it still does not work.

It Generates the following HTML:
<script language="javascript">
<!--
function PilotCheckChanged()
{
alert("Check Changed!");
txtPILOT.Enabled = !chkPilot.Checked;
}
//-->
</script>

However it when I attached the scipt to the chkPilot using the Attributes it
generates a <Span OnCheckedChanged="PilotCheckChanged();"> tag .

Should this have added this code to the actual <ASP:Checkbox> tag?
Or will this being wrapped in a <Span> tag suffice?
 
Back
Top