473,287 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

ASP.NET 2.0 Treeview No Postback?

Hi All,
I have a form that displays hierarchical categories in a treeview. Ok so
far so good. What I was to do is have users be able to select a node in the
treeview as part of filling out the form. I only want to allow single
selection, so using checkboxes is out of the question. It works as is, but
it makes the form very cumbersome if every time that a user selects a node,
the whole page has to reload. Is there a way to have a node become selected
without using postback? I tried setting the navigateurl of all the nodes to
"javascript:void(0);" as was suggested in one post. This works, however, if
a node is currently selected in the tree via server side code, this doesn't
de-select that node. This also doesn't work very well in non-IE browsers.
I also started to experiment using ICallbackEventHandler to use server side
functions without reposting, but that doesn't seem to work in this scenario
(I don't think). Does anyone have any way of getting around this? I really
wish the autopostback property had been built into the treeview like in
other serverside data controls.

Thanks in advance for any help,
Matt
Sep 7 '06 #1
8 12705
Simple way is just to use Atlas. E,g put the TreeView in a UpdatePanel.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


"Matt MacDonald" <ma******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi All,
I have a form that displays hierarchical categories in a treeview. Ok so
far so good. What I was to do is have users be able to select a node in
the treeview as part of filling out the form. I only want to allow single
selection, so using checkboxes is out of the question. It works as is,
but it makes the form very cumbersome if every time that a user selects a
node, the whole page has to reload. Is there a way to have a node become
selected without using postback? I tried setting the navigateurl of all
the nodes to "javascript:void(0);" as was suggested in one post. This
works, however, if a node is currently selected in the tree via server
side code, this doesn't de-select that node. This also doesn't work very
well in non-IE browsers. I also started to experiment using
ICallbackEventHandler to use server side functions without reposting, but
that doesn't seem to work in this scenario (I don't think). Does anyone
have any way of getting around this? I really wish the autopostback
property had been built into the treeview like in other serverside data
controls.

Thanks in advance for any help,
Matt

Sep 7 '06 #2
Can you please explain further? I'm not familiar with Atlas.

Thanks,
Matt

"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:Oh**************@TK2MSFTNGP05.phx.gbl...
Simple way is just to use Atlas. E,g put the TreeView in a UpdatePanel.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


"Matt MacDonald" <ma******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Hi All,
I have a form that displays hierarchical categories in a treeview. Ok
so far so good. What I was to do is have users be able to select a node
in the treeview as part of filling out the form. I only want to allow
single selection, so using checkboxes is out of the question. It works
as is, but it makes the form very cumbersome if every time that a user
selects a node, the whole page has to reload. Is there a way to have a
node become selected without using postback? I tried setting the
navigateurl of all the nodes to "javascript:void(0);" as was suggested in
one post. This works, however, if a node is currently selected in the
tree via server side code, this doesn't de-select that node. This also
doesn't work very well in non-IE browsers. I also started to experiment
using ICallbackEventHandler to use server side functions without
reposting, but that doesn't seem to work in this scenario (I don't
think). Does anyone have any way of getting around this? I really wish
the autopostback property had been built into the treeview like in other
serverside data controls.

Thanks in advance for any help,
Matt


Sep 8 '06 #3
It is Microsoft's implementation of AJAX: See http://atlas.asp.net

With it you can make page work without visible postbacks while still keeping
the server-side functionality.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Matt MacDonald" <ma******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Can you please explain further? I'm not familiar with Atlas.

Thanks,
Matt

"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:Oh**************@TK2MSFTNGP05.phx.gbl...
>Simple way is just to use Atlas. E,g put the TreeView in a UpdatePanel.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


"Matt MacDonald" <ma******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>Hi All,
I have a form that displays hierarchical categories in a treeview. Ok
so far so good. What I was to do is have users be able to select a node
in the treeview as part of filling out the form. I only want to allow
single selection, so using checkboxes is out of the question. It works
as is, but it makes the form very cumbersome if every time that a user
selects a node, the whole page has to reload. Is there a way to have a
node become selected without using postback? I tried setting the
navigateurl of all the nodes to "javascript:void(0);" as was suggested
in one post. This works, however, if a node is currently selected in
the tree via server side code, this doesn't de-select that node. This
also doesn't work very well in non-IE browsers. I also started to
experiment using ICallbackEventHandler to use server side functions
without reposting, but that doesn't seem to work in this scenario (I
don't think). Does anyone have any way of getting around this? I
really wish the autopostback property had been built into the treeview
like in other serverside data controls.

Thanks in advance for any help,
Matt



Sep 9 '06 #4
Does anybody have any more information about this?

Thanks,
Matt

"Matt MacDonald" <ma******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Can you please explain further? I'm not familiar with Atlas.

Thanks,
Matt

"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:Oh**************@TK2MSFTNGP05.phx.gbl...
>Simple way is just to use Atlas. E,g put the TreeView in a UpdatePanel.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


"Matt MacDonald" <ma******@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>Hi All,
I have a form that displays hierarchical categories in a treeview. Ok
so far so good. What I was to do is have users be able to select a node
in the treeview as part of filling out the form. I only want to allow
single selection, so using checkboxes is out of the question. It works
as is, but it makes the form very cumbersome if every time that a user
selects a node, the whole page has to reload. Is there a way to have a
node become selected without using postback? I tried setting the
navigateurl of all the nodes to "javascript:void(0);" as was suggested
in one post. This works, however, if a node is currently selected in
the tree via server side code, this doesn't de-select that node. This
also doesn't work very well in non-IE browsers. I also started to
experiment using ICallbackEventHandler to use server side functions
without reposting, but that doesn't seem to work in this scenario (I
don't think). Does anyone have any way of getting around this? I
really wish the autopostback property had been built into the treeview
like in other serverside data controls.

Thanks in advance for any help,
Matt



Sep 14 '06 #5
Hi Matt,

ATLAS is the MS flavour of AJAX, asynchronous javascript and XML. It's a
framework that integrates into VS2005. You can get it from atlas.asp.net.

As for the updatepanel, the good news is that you'll only need a few
lines around the tree to achieve partial updating of the page. Have a
look at
http://atlas.asp.net/docs/atlas/doc/...px#updatepanel
which shows how to use the updatepanel.

Hope this helps,

Regards,

Roland

Matt MacDonald schrieb:
Does anybody have any more information about this?
>>Simple way is just to use Atlas. E,g put the TreeView in a UpdatePanel.
Sep 14 '06 #6
re:
ATLAS is the MS flavour of AJAX
Not for long...

http://weblogs.asp.net/scottgu/archi...d-Roadmap.aspx
"As part of releasing "Atlas", we have also finally locked on an
official set of product names that we will begin using moving forward.

What was formerly called "Atlas" will now have a few names:

1) The client-side "Atlas" javascript library is going to be called the Microsoft AJAX Library.

2) The server-side "Atlas" functionality that nicely integrates
with ASP.NET will be called the ASP.NET 2.0 AJAX Extensions.

As part of this change the tag prefix for the "Atlas"
controls will change from <atlas:>to <asp:>.

3) The "Atlas" Control Toolkit today is a set of free, shared source controls and
components that help you get the most value from the ASP.NET AJAX Extensions.

Going forward, the name of the project will change
to be the ASP.NET AJAX Control Toolkit.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================

"Roland Dick" <br*****@web.dewrote in message news:ut**************@TK2MSFTNGP05.phx.gbl...
Hi Matt,

ATLAS is the MS flavour of AJAX, asynchronous javascript and XML. It's a framework that integrates
into VS2005. You can get it from atlas.asp.net.

As for the updatepanel, the good news is that you'll only need a few lines around the tree to
achieve partial updating of the page. Have a look at
http://atlas.asp.net/docs/atlas/doc/...px#updatepanel
which shows how to use the updatepanel.

Hope this helps,

Regards,

Roland

Matt MacDonald schrieb:
>Does anybody have any more information about this?
>>>Simple way is just to use Atlas. E,g put the TreeView in a UpdatePanel.

Sep 14 '06 #7
I am having the same issue, and the responses to this question seem to be
missing the point entirely. I've seen this question in a few places on the
web, and their answers also seem to miss the point. I'm starting to wonder
if I'm crazy, although I can see that others are having the same problem I am.

In my case, I have a hierarchy of facilities that I need to manage. I have
a TreeView on the left side of the page showing the hierarchy, and three
buttons to the right: "Add," "Edit," and "Delete." The user first selects a
site in the TreeView, then clicks one of the three buttons to the right to
indicate what they want to do with the site. Only after that button click do
I want a PostBack to the server.

This actually works properly using the pre-.NET2.0 TreeView (i.e., the
Microsoft IE WebControls TreeView control).

With the .NET 2.0 TreeView, I can't for the life of me figure out how to
select a node (i.e., have its style change to SelectedNodeStyle, and its ID
recorded as the SelectedNode client-side) without an immediate PostBack.

It's as if the TreeView engineers never fathomed that someone would want to
do *anything* besides (a) immediately PostBack, or (b) immediately navigate
away from the page, when a user selects a node in the TreeView. I know this
can't be right. (And this is oversimplified -- by setting
<node>.SelectAction = TreeNodeSelectAction.Expand or .None, I can get
client-based behavior -- but not the behavior I want.)

Investigating this problem, I decided to take a peek inside the TreeView
JavaScript library and see what's going on there. I did a View Source and
found a couple of "<script src=" statements, and the second one turned out to
be the one emitted for TreeView pages... so I plugged that URL directly into
my Address bar and saved the .js file to my desktop.

Inside this file, among other things, appears a definition for:
"TreeView_SelectNode(data, node, nodeId)". This function is actually called
from within my .aspx page. The problem is that, while I can see the emitted
JavaScript for the call
[TreeView_SelectNode(ctl00_Content_ctl00_tvOutages_ Data,
this,'ctl00_Content_ctl00_tvOutagest5');], I have no idea how to write C#
code on the server that will emit the proper parameters for each individual
TreeNode. (In case you're wondering, I have a MasterPage, and this call
occurs from within a ContentPlaceHolder called "Content".)

The TreeView_SelectNode function does three things: (1) un-applies the
"selected" style from the currently-selected node, if any; (2) applies the
"selected" style to the newly-selected node, and (3) records the ID of the
newly-selected node in a JavaScript structure intended to track TreeView
state on the client (passed into the function as the "data" parameter).

I don't want to write an entire parallel JavaScript function for selecting
nodes when I know that there's one built into the TreeView's JavaScript
library. Does anyone know how this library works well enough to help write
the appropriate calls to do client-side node selection? Or is there a better
way to do this that I'm just missing?

Thanks,

-Bryan

"Matt MacDonald" wrote:
Hi All,
I have a form that displays hierarchical categories in a treeview. Ok so
far so good. What I was to do is have users be able to select a node in the
treeview as part of filling out the form. I only want to allow single
selection, so using checkboxes is out of the question. It works as is, but
it makes the form very cumbersome if every time that a user selects a node,
the whole page has to reload. Is there a way to have a node become selected
without using postback? I tried setting the navigateurl of all the nodes to
"javascript:void(0);" as was suggested in one post. This works, however, if
a node is currently selected in the tree via server side code, this doesn't
de-select that node. This also doesn't work very well in non-IE browsers.
I also started to experiment using ICallbackEventHandler to use server side
functions without reposting, but that doesn't seem to work in this scenario
(I don't think). Does anyone have any way of getting around this? I really
wish the autopostback property had been built into the treeview like in
other serverside data controls.

Thanks in advance for any help,
Matt
Oct 27 '06 #8
The only way i have found to remove hyperlink in a TreeView is to
iterate the TreeNodeCollection recusively and set the SelectAction to
TreeNodeSelectAction.None

Here's an example:

//recursive method
internal TreeView RemoveHyperLinks(TreeView treeView,
TreeNodeCollection treeNodes)
{
foreach (TreeNode node in treeNodes)
{
node.SelectAction = TreeNodeSelectAction.None;//here
the link is removed
if (node.ChildNodes != null && node.ChildNodes.Count >
0)
{
treeView = RemoveHyperLinks(treeView,
node.ChildNodes);
}
}
return treeView;
}

//initial call:
_treeView = RemoveHyperLinks(_treeView, _treeView.Nodes);
Let me know if this works for you

thx
//AndersR

Nov 30 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ersin inan | last post by:
Hi All, Is there a way to prevent TreeView web control to do PostBack on expand/collapse events? Just do it on selectedindexchanged. Any help is appreciated Best Regards Ersin INAN Turkey
2
by: George M. | last post by:
I'm working with the treeview control on an ASP.NET page (written in C#), and I have one built the looks something like: Root |_Category1 |_Site1 |_Report1 |_Report2 |_Site2 |_Report3...
2
by: Harold | last post by:
I have page A with form field and a button and when button is clicked it opens page B in another window. Page B has a treeview control and that is all. When something is selected I want the page...
0
by: ali element via .NET 247 | last post by:
(Type your message here) -------------------------------- From: ali element Hi, I have a IE treeview which I can populate on the fly. However,when I hit the page the following property must...
0
by: Dave | last post by:
I have a Web Site that is/was built using VS2005 Team Edition for Software Developers (C#). The Data Source points to a Web.SiteMap. The Nodes point to other pages on the same site. The problem...
2
by: rockdale | last post by:
Hi, I have a treeview and in the page load event I populate the treeview completely. I do not have any server side event for the treeview. But still when the user click on a node, the treeview...
2
by: pbd22 | last post by:
Hi. Can somebody tell me how to prevent a postback when I click on the little "plus" sign next to the treenode's root folder? It postbacks and I have to restart a video stream coming to the...
1
by: =?Utf-8?B?Rmx5Z3V5?= | last post by:
I have a TreeView with so many nodes that it requires scroll bars. When the user selects a node the screen is refreshed and the selected node is no longer visible. The TreeView is opened to the...
0
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a treeview setup on my page. In case it is relevant, it is set in an accordion, which is inside an update panel. When I click the treeview node, a page loads on the right side of my browser...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.