Question

Refresh UpdatePanel via JavaScript cause a full postback

Asked by: andre72

Hi,

at my side I use a UpdatePanel and a TreeView.
The links of the TreeView are just JavaScript calls I add to programmatically when the page is load, eg.: root.NavigateUrl = "javascript:UpdPanelUpdate('" + id + "');";

The UpdatePanel looks like this:
<asp:UpdatePanel ID="UpdatePanel0" runat="server" OnLoad="UpdatePanel0_Load">

I found that sample to just refresh the UpdatePanel using JavaScript somewhere in the net:
function UpdPanelUpdate(id) {
    __doPostBack("<%= UpdatePanel0.ClientID %>", id);
}

But when the JavaScript is executed from a click of the TreeView there'll ever be a full page callback.

Any idea what I do wrong?

Thanks,

Andre

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-08-18 at 05:59:22ID24661199
Tags

ASP

,

NET

,

C#

,

JavaScript

,

AJAX

Topics

Programming for ASP.NET

,

JavaScript

,

Asynchronous Javascript and XML (AJAX)

Participating Experts
3
Points
500
Comments
27

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Javascript call is doing postback on updatePanel instead of …
    I have a masterpage and a content page. I have a script manager in the masterpage and an updatePanel in the content page. I want to update the updatepanel via Javascript. With a masterpage, it is doing a full page postback. See code below. When I don't use a masterpage, ...
  2. updatePanel
    the updatePanel solution looks like a magic . My questionis: what is the advantages and disadvantages ? When to use is and when not ? speed ? Thank you Asi
  3. using __doPostBack to fire linkbutton server-side event …
    i have a linkbutton in an updatepanel with a server-side event tied to the Click event of the linkbutton. under normal circumstances this is fine, however, i would like to fire some client-side functions prior to the postback of the updatepanel. i figured the best way to do t...
  4. UpdatePanel not working?
    I have a control on an update panel. The control has a bunch of child controls that are added dynamically at runtime. The child controls each have a radio button, that, when clicked, causes a postback by calling the javascript method __doPostback( ) that ASP .NET provides...
  5. Updatepanel and determining type of postback?
    I have an Obout treeview control that when a node is clicked, sends a DoPostBack that triggers my UpdatePanel to do an asyncpostback. The server then determines what was clicked and in turn hides all 5 Panels contained in the UpdatePanel and unhides the Panel that is associa...
  6. how do i use datimepicker in updatepanel
    i have a datetimepicker placed into a updatepanel,it work correctly but after first updatepanel callback that datetimepicker does not popup. Help me to solve this problem,plz.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: davrob60Posted on 2009-08-18 at 06:33:19ID: 25122988

that code is to cause a full postback,

here a solution

http://codeclimber.net.nz/archive/2007/06/26/how-to-refresh-an-updatepanel-from-javascript.aspx

The idea is to use another control that have async trigger (the control is hidden using style="display:none;") ,

Then use javascript to "push" that trigger.

 


 

by: paololabePosted on 2009-08-18 at 07:13:23ID: 25123409

If you are executing that javascript in a click then you could add a server control, ie:
<asp:LinkButton id="MYLINK" runat="server" click="MYLINK_Click">link</asp:LinkButton>
and put it inside the update panel or add it as a trigger for the update panel.
on every click the updatepanel will reload, if you want you coul also add the code to update the tree in the click event handler.

 

by: andre72Posted on 2009-08-18 at 07:20:14ID: 25123500

Are you really it happens because of the UpdatePanel?
When I use davrob60 link I get also a full page postback.

Maybe because of the TreeView?

 

by: davrob60Posted on 2009-08-18 at 07:22:58ID: 25123536

a click of the TreeView

dos the treeview is instde the update panel.

and Why you just dont add the treeview as a Asyncpostbacktrigger of the updatepanel, you wont need any javascript...

 

by: davrob60Posted on 2009-08-18 at 07:37:45ID: 25123695

ok, i think i missundwerstood what you are tring to do

first forget about that javascript thing.

then, add a the tree view as a asynkpostpacktrigger of your upadat panel

finally, use the selectednodechanged event of the treeview to do your stuff. you will be able to use the .SelectedNode proprety to know witch node was clicked.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.selectednodechanged.aspx

 

by: vazglPosted on 2009-08-18 at 07:43:17ID: 25123756

Hi

Try postback on one of the triggers of the update panel instead of the update panel.

 

by: paololabePosted on 2009-08-18 at 08:34:06ID: 25124311

check the code attached, contains a little example of an updatepanel with a dynamic treeview
remember to add the required section on web.config to enable ajax features

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
 
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Auto">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Inline">
            <ContentTemplate>
                
                
                <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
                <asp:TreeView ID="TreeView1" runat="server">
                </asp:TreeView>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="LinkButton1" EventName="Click" />
            </Triggers>
            
        </asp:UpdatePanel>
       
       </div>
    </form>
</body>
</html>
 
 
------------------------ code behind -----------------------
 
 
Partial Class _Default
    Inherits System.Web.UI.Page
 
  
    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        TreeView1.Nodes.Add(New TreeNode("Ciao"))
        LinkButton1.Text = DateTime.Now
 
    End Sub
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        If Not IsPostBack Then Response.Write(DateTime.Now)
 
    End Sub
End Class
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:

Select allOpen in new window

 

by: andre72Posted on 2009-08-18 at 12:16:12ID: 25126523

Thanks paololabe but this is not what I need.
My TreeView is outside the update panel and when a node is selected it should give an ID to the updatepanel, the panel get data from a db and fill the inputfields.

I'll have a look now for the hints here and when it wouldn't work I'll post the source.

 

by: davrob60Posted on 2009-08-18 at 12:20:30ID: 25126567

Has i said, you could use the selectednodechanged event  and treeview.SelectedNode.id.

if your treeview is set has a asyncPostbackTrigger, then you will bw able to perform your update without the full postback.

 

by: andre72Posted on 2009-08-18 at 23:43:37ID: 25130085

Yes davrob60 I mean your idea to give it a try.

I added a trigger to the updatepanel:
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="TreeView1" />
</Triggers>

and also with EventName="SelectedNodeChanged".

When I add nothing to NavigateUrl I get a full postback.
When I add "javascript: return false;" I get a JS error: return outside a functionen ?!?!
When I add "#" there'll be no event that fires, no postback and no SelectedNodeChanged.

 

by: paololabePosted on 2009-08-19 at 02:56:03ID: 25130947

I'm sorry, no problem, see the attached code.
I think that the problem is that you're using navigateurl, use selectednodechanged events and update the control panel
As said by the other expert you ahve to include treeview in trigger list.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
 
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        
    <div>
        <asp:TreeView ID="TreeView1" runat="server">
        <Nodes>
        <asp:TreeNode Text="link1" Value="link1"></asp:TreeNode>
            <asp:TreeNode Text="link2" Value="link2"></asp:TreeNode>
        </Nodes>
        </asp:TreeView>
        <asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Auto">
        </asp:ScriptManager>
        &nbsp;
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Label Text="Label" ID="Label2" runat="server"></asp:Label>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="TreeView1" EventName="SelectedNodeChanged" />
            </Triggers>
            
        </asp:UpdatePanel>
       
       </div>
    </form>
</body>
</html>
 
------ code behind ------
 
 
Partial Class _Default
    Inherits System.Web.UI.Page
 
  
    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        TreeView1.Nodes.Add(New TreeNode("Ciao"))
        'LinkButton1.Text = DateTime.Now
 
    End Sub
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
        If Not IsPostBack Then Response.Write(DateTime.Now)
 
    End Sub
 
    Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.SelectedNodeChanged
        Label2.Text = TreeView1.SelectedNode.Value
 
    End Sub
End Class
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:

Select allOpen in new window

 

by: davrob60Posted on 2009-08-19 at 05:44:04ID: 25131930

When I add nothing to NavigateUrl I get a full postback.

Humm, this is not normal. if paololabe`s comment dose not help, could you send us some code we could look at?

 

by: andre72Posted on 2009-08-19 at 06:36:14ID: 25132412

I'm sorry about I can't make it work.
So I do what you suggest ...

tvwFramework1_SelectedNodeChanged will never fired but ever the full postback.
Thanks for your suppoert

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;
        border: solid 1px #6699CC;">
        <tr style="height: 200px;">
            <td runat="server" id="tdTree1" style="width: 20%; height: 100%;" align="left" valign="top">
                <div runat="server" id="divTree1" style="width: 20%; height: 100%; overflow: auto;
                    padding: 0px; margin: 0px; bottom: 0;">
                    <asp:TreeView ID="tvwFramework1" runat="server" ShowLines="True" Style="width: 100%;
                        height: 100%; padding: 0px; margin: 0px;">
                        <Nodes>
                            <asp:TreeNode Text=".NET Framework" Value=".NET Framework">
                                <asp:TreeNode Text="System.Diagnostics" Value="System.Diagnostics">
                                    <asp:TreeNode Text="Debug Class" Value="Debug"></asp:TreeNode>
                                    <asp:TreeNode Text="DebuggableAttribute.DebuggingModes Enumeration" Value="DebuggableAttribute.DebuggingModes Enumeration">
                                    </asp:TreeNode>
                                    <asp:TreeNode Text="EventLogPermissionEntryCollection Class" Value="EventLogPermissionEntryCollection Class">
                                    </asp:TreeNode>
                                </asp:TreeNode>
                                <asp:TreeNode Text="System.IO" Value="System.IO">
                                    <asp:TreeNode Text="File Class" Value="File Class"></asp:TreeNode>
                                    <asp:TreeNode Text="FileInfo Class" Value="FileInfo Class"></asp:TreeNode>
                                    <asp:TreeNode Text="InternalBufferOverflowException Class" Value="InternalBufferOverflowException Class">
                                    </asp:TreeNode>
                                </asp:TreeNode>
                                <asp:TreeNode Text="System.Web.UI.WebControls" Value="ASP.NET">
                                    <asp:TreeNode Text="CheckBoxList Class" Value="CheckBoxList"></asp:TreeNode>
                                    <asp:TreeNode Text="Content Class" Value="Content"></asp:TreeNode>
                                    <asp:TreeNode Text="ContentPlaceHolder Class" Value="ContentPlaceHolder"></asp:TreeNode>
                                    <asp:TreeNode Text="Label Class" Value="Label"></asp:TreeNode>
                                    <asp:TreeNode Text="TextBox Class" Value="TextBox"></asp:TreeNode>
                                </asp:TreeNode>
                                <asp:TreeNode Text="System.Web" Value="System.Web">
                                    <asp:TreeNode Text="HttpRequest Class" Value="HttpRequest Class"></asp:TreeNode>
                                    <asp:TreeNode Text="HttpWorkerRequest Class" Value="HttpWorkerRequest Class"></asp:TreeNode>
                                    <asp:TreeNode Text="HttpWorkerRequest.EndOfSendNotification Delegate" Value="HttpWorkerRequest.EndOfSendNotification Delegate">
                                    </asp:TreeNode>
                                </asp:TreeNode>
                                <asp:TreeNode Text="System.Web.Caching" Value="System.Web.Caching">
                                    <asp:TreeNode Text="AggregateCacheDependency Class" Value="AggregateCacheDependency Class">
                                    </asp:TreeNode>
                                    <asp:TreeNode Text="DatabaseNotEnabledForNotificationException Class" Value="DatabaseNotEnabledForNotificationException Class">
                                    </asp:TreeNode>
                                    <asp:TreeNode Text="SqlCacheDependency Class" Value="SqlCacheDependency Class"></asp:TreeNode>
                                </asp:TreeNode>
                                <asp:TreeNode Text="System.Web.UI.MobileControls" Value="System.Web.UI.MobileControls">
                                    <asp:TreeNode Text="DeviceSpecific Class" Value="DeviceSpecific Class"></asp:TreeNode>
                                    <asp:TreeNode Text="LiteralTextContainerControlBuilder Class" Value="LiteralTextContainerControlBuilder Class">
                                    </asp:TreeNode>
                                    <asp:TreeNode Text="ObjectListShowCommandsEventHandler Delegate" Value="ObjectListShowCommandsEventHandler Delegate">
                                    </asp:TreeNode>
                                </asp:TreeNode>
                                <asp:TreeNode Text="System.Web.UI.MobileControls.Adapters" Value="System.Web.UI.MobileControls.Adapters">
                                    <asp:TreeNode Text="HtmlAdapter Class" Value="HtmlAdapter Class"></asp:TreeNode>
                                    <asp:TreeNode Text="HtmlPanelAdapter Class" Value="HtmlPanelAdapter Class"></asp:TreeNode>
                                    <asp:TreeNode Text="WmlControlAdapter Class" Value="WmlControlAdapter Class"></asp:TreeNode>
                                </asp:TreeNode>
                                <asp:TreeNode Text="System.Web.UI.MobileControls.Adapters.XhtmlAdapters" Value="System.Web.UI.MobileControls.Adapters.XhtmlAdapters">
                                    <asp:TreeNode Text="XhtmlCalendarAdapter Class " Value="XhtmlCalendarAdapter Class ">
                                    </asp:TreeNode>
                                    <asp:TreeNode Text="XhtmlCommandAdapter Class" Value="XhtmlCommandAdapter Class">
                                    </asp:TreeNode>
                                    <asp:TreeNode Text="XhtmlFormAdapter Class" Value="XhtmlFormAdapter Class"></asp:TreeNode>
                                </asp:TreeNode>
                            </asp:TreeNode>
                        </Nodes>
                    </asp:TreeView>
                </div>
            </td>
            <td id="tdMid1" style="height: 100%; width: 6px; background-color: Scrollbar;">
            </td>
            <td id="tdEdit1" align="left" valign="top" style="height: 100%; padding-left: 6px;">
                &nbsp;<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
                    <cc1:TabPanel runat="server" HeaderText="Tab1" ID="TabPanel1">
                        <ContentTemplate>
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <asp:Label Text="Label" ID="Label2" runat="server"></asp:Label>
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="tvwFramework1" EventName="SelectedNodeChanged" />
                                </Triggers>
                            </asp:UpdatePanel>
                        </ContentTemplate>
                    </cc1:TabPanel>
                    <cc1:TabPanel runat="server" HeaderText="Tab2" ID="TabPanel2">
                        <ContentTemplate>
                        </ContentTemplate>
                    </cc1:TabPanel>
                    <cc1:TabPanel runat="server" HeaderText="Tab3" ID="TabPanel3">
                        <ContentTemplate>
                        </ContentTemplate>
                    </cc1:TabPanel>
                </cc1:TabContainer>
            </td>
        </tr>
    </table>
</asp:Content>
 
------ code behind ------
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    protected void tvwFramework1_SelectedNodeChanged(Object sender, System.EventArgs e)
    {
        Label2.Text = DateTime.Now.ToString();
    }
}

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:

Select allOpen in new window

 

by: davrob60Posted on 2009-08-19 at 06:39:08ID: 25132446

ha! ther is a tab container!

If you put the update panel out of the tab container, does it work???

 

by: andre72Posted on 2009-08-19 at 06:58:45ID: 25132673

No, the behaviour is the same like inside the tabs ...

 

by: davrob60Posted on 2009-08-19 at 07:02:19ID: 25132702

 

by: davrob60Posted on 2009-08-19 at 07:09:25ID: 25132790

FYI I also found this :

http://msdn.microsoft.com/en-us/library/e8z5184w.aspx

abstract :

 

Using the TreeView Control with UpdatePanel Controls

  • UpdatePanel controls are used to update selected regions of a page instead of updating the whole page with a postback. The TreeView control can be used inside an UpdatePanel control with the following restrictions:  
  • TreeView callbacks must be associated with asynchronous postbacks, or callback event validation will fail. When you set the PopulateOnDemand property of the TreeNode controls to true, callbacks are enabled. You can use one of the following approaches to ensure that TreeView callbacks work with the UpdatePanel control:  
    • If the TreeView control is not inside an UpdatePanel control, disable callbacks on TreeNode controls that are not part of an asynchronous postback. To do this, set the PopulateOnDemand property to false.  
    • Programmatically refresh all controls that register callbacks during the asynchronous postback. For example, you can place the TreeView control inside an UpdatePanel control. The TreeView control does not have to be in the UpdatePanel control where the asynchronous postback originates, as long as the UpdatePanel control that contains the TreeView control is refreshed. 
  • You must apply styles by using a reference to a Cascading Style Sheet (CSS) class. For example, instead of setting the NodeStyle property by using a property-subproperty attribute, set the style by using the property-CssClass attribute. Similarly, when you use the NodeStyle template to set the style, use the CssClass attribute of the template.  
  • The EnableClientScript property must be true (the default value). In addition, if callbacks are enabled for the TreeView control, you cannot change the EnableClientScript property between asynchronous postbacks.

     

 

by: andre72Posted on 2009-08-19 at 07:14:19ID: 25132855

The same ...
It seems that the TreeView is really strange ...

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;
        border: solid 1px #6699CC;">
        <tr style="height: 200px;">
            <td runat="server" id="tdTree1" style="width: 20%; height: 100%;" align="left" valign="top">
                <div runat="server" id="divTree1" style="width: 20%; height: 100%; overflow: auto;
                    padding: 0px; margin: 0px; bottom: 0;">
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <ContentTemplate>
                            <asp:TreeView ID="tvwFramework1" runat="server" ShowLines="True" Style="width: 100%;
                                height: 100%; padding: 0px; margin: 0px;">
                                <Nodes>
                                    <asp:TreeNode Text=".NET Framework" Value=".NET Framework">
                                        <asp:TreeNode Text="System.Diagnostics" Value="System.Diagnostics">
                                            <asp:TreeNode Text="Debug Class" Value="Debug"></asp:TreeNode>
                                            <asp:TreeNode Text="DebuggableAttribute.DebuggingModes Enumeration" Value="DebuggableAttribute.DebuggingModes Enumeration">
                                            </asp:TreeNode>
                                            <asp:TreeNode Text="EventLogPermissionEntryCollection Class" Value="EventLogPermissionEntryCollection Class">
                                            </asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="System.IO" Value="System.IO">
                                            <asp:TreeNode Text="File Class" Value="File Class"></asp:TreeNode>
                                            <asp:TreeNode Text="FileInfo Class" Value="FileInfo Class"></asp:TreeNode>
                                            <asp:TreeNode Text="InternalBufferOverflowException Class" Value="InternalBufferOverflowException Class">
                                            </asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="System.Web.UI.WebControls" Value="ASP.NET">
                                            <asp:TreeNode Text="CheckBoxList Class" Value="CheckBoxList"></asp:TreeNode>
                                            <asp:TreeNode Text="Content Class" Value="Content"></asp:TreeNode>
                                            <asp:TreeNode Text="ContentPlaceHolder Class" Value="ContentPlaceHolder"></asp:TreeNode>
                                            <asp:TreeNode Text="Label Class" Value="Label"></asp:TreeNode>
                                            <asp:TreeNode Text="TextBox Class" Value="TextBox"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="System.Web" Value="System.Web">
                                            <asp:TreeNode Text="HttpRequest Class" Value="HttpRequest Class"></asp:TreeNode>
                                            <asp:TreeNode Text="HttpWorkerRequest Class" Value="HttpWorkerRequest Class"></asp:TreeNode>
                                            <asp:TreeNode Text="HttpWorkerRequest.EndOfSendNotification Delegate" Value="HttpWorkerRequest.EndOfSendNotification Delegate">
                                            </asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="System.Web.Caching" Value="System.Web.Caching">
                                            <asp:TreeNode Text="AggregateCacheDependency Class" Value="AggregateCacheDependency Class">
                                            </asp:TreeNode>
                                            <asp:TreeNode Text="DatabaseNotEnabledForNotificationException Class" Value="DatabaseNotEnabledForNotificationException Class">
                                            </asp:TreeNode>
                                            <asp:TreeNode Text="SqlCacheDependency Class" Value="SqlCacheDependency Class"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="System.Web.UI.MobileControls" Value="System.Web.UI.MobileControls">
                                            <asp:TreeNode Text="DeviceSpecific Class" Value="DeviceSpecific Class"></asp:TreeNode>
                                            <asp:TreeNode Text="LiteralTextContainerControlBuilder Class" Value="LiteralTextContainerControlBuilder Class">
                                            </asp:TreeNode>
                                            <asp:TreeNode Text="ObjectListShowCommandsEventHandler Delegate" Value="ObjectListShowCommandsEventHandler Delegate">
                                            </asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="System.Web.UI.MobileControls.Adapters" Value="System.Web.UI.MobileControls.Adapters">
                                            <asp:TreeNode Text="HtmlAdapter Class" Value="HtmlAdapter Class"></asp:TreeNode>
                                            <asp:TreeNode Text="HtmlPanelAdapter Class" Value="HtmlPanelAdapter Class"></asp:TreeNode>
                                            <asp:TreeNode Text="WmlControlAdapter Class" Value="WmlControlAdapter Class"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="System.Web.UI.MobileControls.Adapters.XhtmlAdapters" Value="System.Web.UI.MobileControls.Adapters.XhtmlAdapters">
                                            <asp:TreeNode Text="XhtmlCalendarAdapter Class " Value="XhtmlCalendarAdapter Class ">
                                            </asp:TreeNode>
                                            <asp:TreeNode Text="XhtmlCommandAdapter Class" Value="XhtmlCommandAdapter Class">
                                            </asp:TreeNode>
                                            <asp:TreeNode Text="XhtmlFormAdapter Class" Value="XhtmlFormAdapter Class"></asp:TreeNode>
                                        </asp:TreeNode>
                                    </asp:TreeNode>
                                </Nodes>
                            </asp:TreeView>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
            </td>
            <td id="tdMid1" style="height: 100%; width: 6px; background-color: Scrollbar;">
            </td>
            <td id="tdEdit1" align="left" valign="top" style="height: 100%; padding-left: 6px;">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:Label Text="Label" ID="Label2" runat="server"></asp:Label>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="tvwFramework1" EventName="SelectedNodeChanged" />
                    </Triggers>
                </asp:UpdatePanel>
                &nbsp;<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
                    <cc1:TabPanel runat="server" HeaderText="Übersicht" ID="TabPanel1">
                        <HeaderTemplate>
                            Übersicht
                        </HeaderTemplate>
                        <ContentTemplate>
                        </ContentTemplate>
                    </cc1:TabPanel>
                    <cc1:TabPanel runat="server" HeaderText="Eingabe" ID="TabPanel2">
                        <ContentTemplate>
                        </ContentTemplate>
                    </cc1:TabPanel>
                    <cc1:TabPanel runat="server" HeaderText="Kommentare" ID="TabPanel3">
                        <ContentTemplate>
                        </ContentTemplate>
                    </cc1:TabPanel>
                    <cc1:TabPanel runat="server" HeaderText="Sonderartikel" ID="TabPanel4">
                        <ContentTemplate>
                        </ContentTemplate>
                    </cc1:TabPanel>
                    <cc1:TabPanel runat="server" HeaderText="Rabattierung" ID="TabPanel5">
                        <ContentTemplate>
                        </ContentTemplate>
                    </cc1:TabPanel>
                    <cc1:TabPanel runat="server" HeaderText="Optionen" ID="TabPanel6">
                        <ContentTemplate>
                        </ContentTemplate>
                    </cc1:TabPanel>
                </cc1:TabContainer>
            </td>
        </tr>
    </table>
</asp:Content>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:

Select allOpen in new window

 

by: davrob60Posted on 2009-08-19 at 07:23:27ID: 25132980

humm, i`m clueless

The only thing i see is that thing

Style="width: 100%;  height: 100%; padding: 0px; margin: 0px;"

and the MSDN article said

  • You must apply styles by using a reference to a Cascading Style Sheet (CSS) class. For example, instead of setting the NodeStyle property by using a property-subproperty attribute, set the style by using the property-CssClass attribute. Similarly, when you use the NodeStyle template to set the style, use the CssClass attribute of the template.  
     

So, I dont see why it will change anything (voodoo programming, great!), but since Microsoft tell it, what append if you remove the Style property? (and also the ShowLines="True" while we are there)

 

by: andre72Posted on 2009-08-19 at 07:34:31ID: 25133126

What is a little bit funny: When I set PopulateOnDemand="false" EnableClientScript="true" like is described in the article, I get also a full postback ...

davrob60 I'm sorry, I'm not sure it I understand right what to do with the CSS.
Is the meaning like that:
<asp:TreeView ID="tvwFramework1" runat="server" ShowLines="True" Style="width: 100%;
                                height: 100%; padding: 0px; margin: 0px;" PopulateOnDemand="false" EnableClientScript="true">

This is also already used in the source.
But I can't really understand that are so many hints don't work in my case ...

 

by: davrob60Posted on 2009-08-19 at 07:38:27ID: 25133188

i was telling about this:

<asp:TreeView ID="tvwFramework1" runat="server" ShowLines="True" Style="width: 100%; height: 100%; padding: 0px; margin: 0px;" >

so let just try this:

<asp:TreeView ID="tvwFramework1" runat="server" >
 

 

by: paololabePosted on 2009-08-19 at 07:41:44ID: 25133226

I've just paste your code and it works for me, i've just added the code attached
no need to use a second update panel

protected void Page_Load(object
sender, EventArgs e) {
    
        tvwFramework1.SelectedNodeChanged+=new EventHandler(tvwFramework1_SelectedNodeChanged);
    
    }

                                              
1:
2:
3:
4:
5:
6:

Select allOpen in new window

 

by: andre72Posted on 2009-08-19 at 07:51:08ID: 25133338

I agree that is the solution for SelectedNodeChanged.
And you get the Page_Load only once?
I get it with every hit at a node.

 

by: davrob60Posted on 2009-08-19 at 07:51:26ID: 25133344

nice catch paololabe!  

I think you could do the same as paololabe from load by setting the onselectednodechanged property.

<asp:TreeView ID="tvwFramework1" runat="server"             onselectednodechanged="tvwFramework1_SelectedNodeChanged">
                                              
1:

Select allOpen in new window

 

by: paololabePosted on 2009-08-19 at 08:13:08ID: 25133639

>And you get the Page_Load only once?
Page_load will be called for every postback also during a partial rendering, this is by design.
try for example
if(!IsPostBack)  tvwFramework1.SelectedNodeChanged+=new EventHandler(tvwFramework1_SelectedNodeChanged);
the event handler will not be callet at all.

 

by: andre72Posted on 2009-08-19 at 08:39:25ID: 25133989

Sorry, I was a little bit confused for sure you ask with Page.IsPostBack because of a PostBack occurs.
I hope you agree with 50% for the hint with the trigger and 50% for the missing SelectedNodeChanged.

Thanks a lot!

 

by: andre72Posted on 2009-08-19 at 08:40:41ID: 31617023

Thanks

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...