Hi I use the TreeView control inside an ajax update panel. This is working
fine till I just implement the TreeNodeExpanded event. Even without writing
any code inside that implementation!
I open the root everything is fine. I open subnode 1 everything is fine, too.
Now I open subnode1.1 and subnode1 (parent of subnode1.1) closes!
What the???
Here is the code I used to implement that special event:
Protected Sub CategoryTreeView_TreeNodeExpanded(ByVal sender As
System.Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs)
Handles CategoryTreeView.TreeNodeExpanded
'really no code here!!
End Sub
What happens when I debug the code is:
The first time TreeNodeExpanded is called correctly.
But then a full Postback is done.
Next is a new call to TreeNodeCollapsed
-> here the parent of the subnode1.1 is the object calling this handler
(subnode1)!
-> this has the property expanded=false! whyever!
Next another postback is done
Next finally TreeNodeExpanded gets called again with subnode1.1
where expanded property is true!
Did anybody experience the same problem? And if so does a good workaround
exist? I read a fix where in every event of this type: expanded, collapsed,
selectedNodeChange you suppress the closing of the root node but this didn't
solve
my problem since its not the root node but the parent node that wants to
close.
This drove me crazy- perhaps someone has a solution?
I have exactly the same problem: on expanding node another node is closed or node does not want to expand/collapse at all. I think the problem is that client-side java scripts generated by asp tree somehow collide with update panel scripts (?) but i have
no idea how to fix it and also looking for solution.
TreeViews are not supported in update panels. I have heard of a couple people getting it to work by doing stuff in the PreRender event, but we never had it working 100% without errors or other strange behavior. We use the telerik treeview because it didn't
seem to have issues like that, but those third party controls aren't free...
I've been using the treeview in the updatepanel for one year with the following experiences:
- not compatible/not supported in the updatepanel from the beginning
- it worked better in the ctp/beta era!
- any client side functionality: EnableClientScript="true", PopulateNodesFromClient="true" etc. won't work correctly because the controls expanded/selected nodes state (which are stored in hidden fields) corrupted during partial postback (stays out of sync).
I think that is the cause of your problem:
ringdrossel
Now I open subnode1.1 and subnode1 (parent of subnode1.1) closes!
What the???
- you can try with simple treeviews (don't use client side features, viewstate must be enabled, and finally small tree because the treeview viewstate is enormous big). That works for me usually.
Controls that are incompatible with partial-page rendering can still be used on a page outside
UpdatePanel controls. Additionally, in some cases you can use the controls in a specific way to make them compatible with partial-page updates. For example,
you can use the Login,
ChangePassword, or
PasswordRecovery controls inside an
UpdatePanel control if you can convert their contents to templates. (If you are using Visual Studio, in Design view you can convert the controls by using
smart-tag menu commands such as Convert to Template or
Customize Create User Step.) When you convert these controls into editable templates, the validation controls that are used in the control are defined declaratively by using markup in the page. To make the validators compatible with an
UpdatePanel control, set the
EnableClientScript property of the validators to
false. This disables the client script that would ordinarily be used to perform validation in the browser. As a result, during an asynchronous postback, the validators perform validation on the server. However, because only the
content of the UpdatePanel is refreshed, the validators can provide the kind of immediate feedback that is ordinarily provided by client script.
To use a FileUpload control inside an
UpdatePanel control, set the postback control that submits the file to be a
PostBackTrigger control for the panel.
All other controls work inside
UpdatePanel controls. However, in some circumstances, a control might not work as expected inside an
UpdatePanel control. These circumstances include the following:
Registering script by calling registration methods of the
ClientScriptManager control.
Rendering script or markup directly during control rendering, such as by calling the
Write(String) method.
If the control calls script registration methods of the
ClientScriptManager control, you could use corresponding script registration methods of the
ScriptManager control instead. In that case, the control can work inside an
UpdatePanel control.
I advise you using webservice or webmathod to achieve it instead using updatepanel.
ringdrossel
Member
1 Points
9 Posts
Treeview updatepanel problem with AJAX
Jun 04, 2007 09:50 AM|LINK
fine till I just implement the TreeNodeExpanded event. Even without writing
any code inside that implementation!
Here is what happens:
I got a tree structure like
root
- node
-- subnode1
--- subnode1.1
---- subnode1.1.1
--- subnode1.2
-- subnode2
- node2
I open the root everything is fine. I open subnode 1 everything is fine, too.
Now I open subnode1.1 and subnode1 (parent of subnode1.1) closes!
What the???
Here is the code I used to implement that special event:
Protected Sub CategoryTreeView_TreeNodeExpanded(ByVal sender As
System.Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs)
Handles CategoryTreeView.TreeNodeExpanded
'really no code here!!
End Sub
What happens when I debug the code is:
The first time TreeNodeExpanded is called correctly.
But then a full Postback is done.
Next is a new call to TreeNodeCollapsed
-> here the parent of the subnode1.1 is the object calling this handler
(subnode1)!
-> this has the property expanded=false! whyever!
Next another postback is done
Next finally TreeNodeExpanded gets called again with subnode1.1
where expanded property is true!
Did anybody experience the same problem? And if so does a good workaround
exist? I read a fix where in every event of this type: expanded, collapsed,
selectedNodeChange you suppress the closing of the root node but this didn't
solve
my problem since its not the root node but the parent node that wants to
close.
This drove me crazy- perhaps someone has a solution?
Regards Sven
treeview updatepanel
PawelRoman
Member
14 Points
30 Posts
Re: Treeview updatepanel problem with AJAX
Jun 04, 2007 11:20 AM|LINK
I have exactly the same problem: on expanding node another node is closed or node does not want to expand/collapse at all. I think the problem is that client-side java scripts generated by asp tree somehow collide with update panel scripts (?) but i have no idea how to fix it and also looking for solution.
mdenn
Participant
1854 Points
454 Posts
Re: Treeview updatepanel problem with AJAX
Jun 04, 2007 12:49 PM|LINK
TreeViews are not supported in update panels. I have heard of a couple people getting it to work by doing stuff in the PreRender event, but we never had it working 100% without errors or other strange behavior. We use the telerik treeview because it didn't seem to have issues like that, but those third party controls aren't free...
stmarti
Contributor
4963 Points
1036 Posts
Re: Treeview updatepanel problem with AJAX
Jun 04, 2007 04:53 PM|LINK
- not compatible/not supported in the updatepanel from the beginning
- it worked better in the ctp/beta era!
- any client side functionality: EnableClientScript="true", PopulateNodesFromClient="true" etc. won't work correctly because the controls expanded/selected nodes state (which are stored in hidden fields) corrupted during partial postback (stays out of sync). I think that is the cause of your problem:
- you can try with simple treeviews (don't use client side features, viewstate must be enabled, and finally small tree because the treeview viewstate is enormous big). That works for me usually.
Jin-Yu Yin -...
All-Star
21280 Points
1824 Posts
Re: Treeview updatepanel problem with AJAX
Jun 05, 2007 02:43 AM|LINK
Hi,PawelRoman
TreeView is not compatible with partial-page updates, and is therefore not supported inside an UpdatePanel control,
I advise you using webservice or webmathod to achieve it instead using updatepanel.
I advise you using webservice or webmathod to achieve it instead using updatepanel.
You can see these threads for more help: http://forums.asp.net/t/1115137.aspx, http://forums.asp.net/t/1117960.aspx
You can also see these tutorials for more help :
http://ajax.asp.net/docs/tutorials/ExposingWebServicesToAJAXTutorial.aspx.
http://ajax.asp.net/docs/tutorials/ConsumingWebServicesWithAJAXTutorial.aspx
Let me know if you need more info.
If this help you,don't forget mark it as a answer.Thanks!
Jin-Yu Yin
Microsoft Online Community Support