Registerd Client Script Not Working

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.
 
R

Red

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top