Registerd Client Script Not Working

Discussion in 'ASP .Net' started by Red, Apr 24, 2004.

  1. Red

    Red Guest

    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.
    Red, Apr 24, 2004
    #1
    1. Advertising

  2. Red

    Red Guest

    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?


    "Red" <> wrote in message
    news:%...
    > 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("OnCheckedChanged") = "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.
    >
    >
    Red, Apr 24, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob
    Replies:
    1
    Views:
    506
    Raymond Lewallen
    Jun 23, 2004
  2. DanB
    Replies:
    0
    Views:
    1,092
  3. Alan Silver
    Replies:
    1
    Views:
    3,771
    Alan Silver
    Aug 2, 2005
  4. aBs0lut30
    Replies:
    0
    Views:
    299
    aBs0lut30
    Aug 10, 2006
  5. lawrence
    Replies:
    8
    Views:
    244
    lawrence
    May 5, 2004
Loading...

Share This Page