Treeview node, add confirm javascript?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tfsmag

    Treeview node, add confirm javascript?

    Okay, I have a project management app i'm writing and in the left hand
    menu i have a treeview control that is populated with each project...
    in child nodes under each project node I have an "edit" and a "delete"
    node. I have the functionality of the edit and delete working fine, my
    issue is now however that I cannot seem to find a way to add an
    "onclick" event that fires a confirm box. I've tried this method..

    treenode.Text = "<a href=""javascri pt:confirm('con firm text') return
    true;"">text</a>"

    and that fires a confirm, but does nothing when i click on "ok", in
    other words it doesn't delete the project when i confirm.

    Can anyone lend a hand here? Thanks in advance!

    - Jeff

  • Laurent Bugnion

    #2
    Re: Treeview node, add confirm javascript?

    Hi,

    tfsmag wrote:
    Okay, I have a project management app i'm writing and in the left hand
    menu i have a treeview control that is populated with each project...
    in child nodes under each project node I have an "edit" and a "delete"
    node. I have the functionality of the edit and delete working fine, my
    issue is now however that I cannot seem to find a way to add an
    "onclick" event that fires a confirm box. I've tried this method..
    >
    treenode.Text = "<a href=""javascri pt:confirm('con firm text') return
    true;"">text</a>"
    >
    and that fires a confirm, but does nothing when i click on "ok", in
    other words it doesn't delete the project when i confirm.
    First, you should never ever use the javascript: pseudo protocol in a
    HREF. That is known to cause problems. Check comp.lang.javas cript on
    Google News for details.

    Second, of course the code above does nothing. You ignore the return
    value of the "confirm" function. confirm() returns true if OK was
    clicked, false otherwise.

    Finally, you return true in your HREF, but that doesn't help anything.
    What do you want to achieve if the user clicks OK? Call a URL? If yes,
    that should be:

    treenode.Text = "<a href=""aUrl.htm l"" onclick=""retur n confirm('confir m
    text');"">text</a>"

    Sorry, I don't do VB.NET, so I am not totally sure if the syntax is correct.

    HTH,
    Laurent
    --
    Laurent Bugnion, GalaSoft
    Software engineering: http://www.galasoft-LB.ch
    PhotoAlbum: http://www.galasoft-LB.ch/pictures
    Support children in Calcutta: http://www.calcutta-espoir.ch

    Comment

    • tfsmag

      #3
      Re: Treeview node, add confirm javascript?

      thanks laurent, i'm pretty bad with javascript... i'll try your code
      out and see how it goes.

      cheers,
      Jeff

      Laurent Bugnion wrote:
      Hi,
      >
      tfsmag wrote:
      Okay, I have a project management app i'm writing and in the left hand
      menu i have a treeview control that is populated with each project...
      in child nodes under each project node I have an "edit" and a "delete"
      node. I have the functionality of the edit and delete working fine, my
      issue is now however that I cannot seem to find a way to add an
      "onclick" event that fires a confirm box. I've tried this method..

      treenode.Text = "<a href=""javascri pt:confirm('con firm text') return
      true;"">text</a>"

      and that fires a confirm, but does nothing when i click on "ok", in
      other words it doesn't delete the project when i confirm.
      >
      First, you should never ever use the javascript: pseudo protocol in a
      HREF. That is known to cause problems. Check comp.lang.javas cript on
      Google News for details.
      >
      Second, of course the code above does nothing. You ignore the return
      value of the "confirm" function. confirm() returns true if OK was
      clicked, false otherwise.
      >
      Finally, you return true in your HREF, but that doesn't help anything.
      What do you want to achieve if the user clicks OK? Call a URL? If yes,
      that should be:
      >
      treenode.Text = "<a href=""aUrl.htm l"" onclick=""retur n confirm('confir m
      text');"">text</a>"
      >
      Sorry, I don't do VB.NET, so I am not totally sure if the syntax is correct.
      >
      HTH,
      Laurent
      --
      Laurent Bugnion, GalaSoft
      Software engineering: http://www.galasoft-LB.ch
      PhotoAlbum: http://www.galasoft-LB.ch/pictures
      Support children in Calcutta: http://www.calcutta-espoir.ch

      Comment

      • tfsmag

        #4
        Re: Treeview node, add confirm javascript?

        nope.. that still didn't work... when placing javascript inside of the
        text attributes, it is overriding the treenode_click event with what's
        in the javscripts onclick event. Anyone else have any ideas?


        tfsmag wrote:
        thanks laurent, i'm pretty bad with javascript... i'll try your code
        out and see how it goes.
        >
        cheers,
        Jeff
        >
        Laurent Bugnion wrote:
        Hi,

        tfsmag wrote:
        Okay, I have a project management app i'm writing and in the left hand
        menu i have a treeview control that is populated with each project...
        in child nodes under each project node I have an "edit" and a "delete"
        node. I have the functionality of the edit and delete working fine, my
        issue is now however that I cannot seem to find a way to add an
        "onclick" event that fires a confirm box. I've tried this method..
        >
        treenode.Text = "<a href=""javascri pt:confirm('con firm text') return
        true;"">text</a>"
        >
        and that fires a confirm, but does nothing when i click on "ok", in
        other words it doesn't delete the project when i confirm.
        First, you should never ever use the javascript: pseudo protocol in a
        HREF. That is known to cause problems. Check comp.lang.javas cript on
        Google News for details.

        Second, of course the code above does nothing. You ignore the return
        value of the "confirm" function. confirm() returns true if OK was
        clicked, false otherwise.

        Finally, you return true in your HREF, but that doesn't help anything.
        What do you want to achieve if the user clicks OK? Call a URL? If yes,
        that should be:

        treenode.Text = "<a href=""aUrl.htm l"" onclick=""retur n confirm('confir m
        text');"">text</a>"

        Sorry, I don't do VB.NET, so I am not totally sure if the syntax is correct.

        HTH,
        Laurent
        --
        Laurent Bugnion, GalaSoft
        Software engineering: http://www.galasoft-LB.ch
        PhotoAlbum: http://www.galasoft-LB.ch/pictures
        Support children in Calcutta: http://www.calcutta-espoir.ch

        Comment

        • tfsmag

          #5
          Re: Treeview node, add confirm javascript?

          Okay i finally figured it out... Here is how i got it to work

          Dim deletenode As New TreeNode("<span onclick=""javas cript:confirm(' Are
          you sure you want to delete " & dr("ProjectName ") &
          "?');"">Del ete</span>", "0" & dr("ProjectID") )

          This made it work correctly and still fire the SelectedNodeCha nged
          event. I had to use a <spantag because when i used a normal <a href>
          it would override the SelectedNodeCha nged event. Simple solution it
          seems, but man did it take me awhile to figure out!


          tfsmag wrote:
          nope.. that still didn't work... when placing javascript inside of the
          text attributes, it is overriding the treenode_click event with what's
          in the javscripts onclick event. Anyone else have any ideas?
          >
          >
          tfsmag wrote:
          thanks laurent, i'm pretty bad with javascript... i'll try your code
          out and see how it goes.

          cheers,
          Jeff

          Laurent Bugnion wrote:
          Hi,
          >
          tfsmag wrote:
          Okay, I have a project management app i'm writing and in the left hand
          menu i have a treeview control that is populated with each project...
          in child nodes under each project node I have an "edit" and a "delete"
          node. I have the functionality of the edit and delete working fine, my
          issue is now however that I cannot seem to find a way to add an
          "onclick" event that fires a confirm box. I've tried this method..

          treenode.Text = "<a href=""javascri pt:confirm('con firm text') return
          true;"">text</a>"

          and that fires a confirm, but does nothing when i click on "ok", in
          other words it doesn't delete the project when i confirm.
          >
          First, you should never ever use the javascript: pseudo protocol in a
          HREF. That is known to cause problems. Check comp.lang.javas cript on
          Google News for details.
          >
          Second, of course the code above does nothing. You ignore the return
          value of the "confirm" function. confirm() returns true if OK was
          clicked, false otherwise.
          >
          Finally, you return true in your HREF, but that doesn't help anything.
          What do you want to achieve if the user clicks OK? Call a URL? If yes,
          that should be:
          >
          treenode.Text = "<a href=""aUrl.htm l"" onclick=""retur n confirm('confir m
          text');"">text</a>"
          >
          Sorry, I don't do VB.NET, so I am not totally sure if the syntax is correct.
          >
          HTH,
          Laurent
          --
          Laurent Bugnion, GalaSoft
          Software engineering: http://www.galasoft-LB.ch
          PhotoAlbum: http://www.galasoft-LB.ch/pictures
          Support children in Calcutta: http://www.calcutta-espoir.ch

          Comment

          Working...