Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to stop PostBack for Treeview control

How to stop PostBack for Treeview control

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelptutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kuricheti
    wrote on last edited by
    #1

    Hi friends, I'm using asp.net 2.0 Treeview control. This control have some rootnodes and child nodes. on clicking any node(either parent or child node) page is getting refreshed. I want to stop the postback and node should be selected. After selecting the node, in "ADD" button click event i want to catch which node is selected. Anybody already worked with this type of requirement plz help me. Thanks in Advance Hari

    A P 2 Replies Last reply
    0
    • K Kuricheti

      Hi friends, I'm using asp.net 2.0 Treeview control. This control have some rootnodes and child nodes. on clicking any node(either parent or child node) page is getting refreshed. I want to stop the postback and node should be selected. After selecting the node, in "ADD" button click event i want to catch which node is selected. Anybody already worked with this type of requirement plz help me. Thanks in Advance Hari

      A Offline
      A Offline
      AhsanS
      wrote on last edited by
      #2

      Set the autopostback property to false.

      K 1 Reply Last reply
      0
      • A AhsanS

        Set the autopostback property to false.

        K Offline
        K Offline
        Kuricheti
        wrote on last edited by
        #3

        Hi AhsanS, Thanks for the response but there is no AutoPostBack Property for Treeview control. :)

        modified on Thursday, March 13, 2008 8:54 AM

        A 2 Replies Last reply
        0
        • K Kuricheti

          Hi AhsanS, Thanks for the response but there is no AutoPostBack Property for Treeview control. :)

          modified on Thursday, March 13, 2008 8:54 AM

          A Offline
          A Offline
          AhsanS
          wrote on last edited by
          #4

          This link has several solutions: http://forums.asp.net/thread/469254.aspx The best one I found was offered by persky. To use it, backup the treeview.htc file and then open it with notepad or some other text editor. Find the function "nodePlusMinusClick" and replace the entire function with the following code: function nodePlusMinusClick() { if (g_bInteractive == false) return; var el = this.parentElement.treenode; // 2 lines below commented out to disable postback on expand/collapse, extra lines added below for better functionality // if (doNodePlusMinusClick(el) == true) // fireQueuedEvents(); var index = getNodeIndex(el); // if the selected or hovered node was one of the collapsed node's descendants then postback anyway if (selectedNodeIndex.length > index.length && selectedNodeIndex.substr(0,index.length) == index) { if (doNodePlusMinusClick(el) == true) fireQueuedEvents(); } // otherwise just do the expand/collapse stuff else doNodePlusMinusClick(el); }

          Ahsan Ullah Senior Software Engineer

          1 Reply Last reply
          0
          • K Kuricheti

            Hi AhsanS, Thanks for the response but there is no AutoPostBack Property for Treeview control. :)

            modified on Thursday, March 13, 2008 8:54 AM

            A Offline
            A Offline
            AhsanS
            wrote on last edited by
            #5

            there is another solution as well. When you are adding the nodes do this You can disable postbacks for expand/collapse events by Setting the property TreeNode.SelectAction = TreeNodeSelectAction.Expand. This will cause the treenodes to expand/collapse without a postback. If you want to enable postback for a particular node, set the property TreeNode.SelectAction = TreeNodeSelectAction.Select or TreeNodeSelectAction.SelectExpand.

            Ahsan Ullah Senior Software Engineer

            1 Reply Last reply
            0
            • K Kuricheti

              Hi friends, I'm using asp.net 2.0 Treeview control. This control have some rootnodes and child nodes. on clicking any node(either parent or child node) page is getting refreshed. I want to stop the postback and node should be selected. After selecting the node, in "ADD" button click event i want to catch which node is selected. Anybody already worked with this type of requirement plz help me. Thanks in Advance Hari

              P Offline
              P Offline
              P Tagore Srinivas Dhanunjay
              wrote on last edited by
              #6

              Hi Kuricheti, There is no AutoPostBack event in Treeview control. To get the selected text you can use OnSelectedNodeChanged property in .aspx file and point it to some function. eg. OnSelectedNodeChanged="SelectCategory"> to get the selected value write a function in C# and use TREEVIEWID.SelectedNode.Text eg. tbCategory.Text = tvCategories.SelectedNode.Text; Try it out.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups