CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 11/29/2007 9:49:13 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 106 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
rmdw
Asp.Net User
Trying to get button to expand/collapse menu11/29/2007 9:49:13 PM

-1/1

I have a Treeview acting as a menu on the left side of my web app pages.  Below this I have a simple LinkButton that I want to alternate between "Open Menu" and "Close Menu".  Both the Treeview and the LinkButton sit within an AJAX Update Panel but for both the Update Panel and the LinkButton have EnableViewState="true".

What I'm puzzled by is that in the LinkButton's event handler the text of the button always seems to contain "Open Menu", even though I can clearly see that it shows "Close Menu" on the screen.  As such, I can't properly toggle the menu open/close/open/close etc.

What more do I need to do to be able to check the text of the LinkButton to determine whether the Treeview is expanded or collapsed?

Robert 


Robert Werner
Vancouver, BC
www.pocketpollster.com
Amanda Wang - M
Asp.Net User
Re: Trying to get button to expand/collapse menu12/3/2007 7:54:18 AM

0/0

Hi,

Base  on your description, do you want to use the linkbutton to expand or collapse menu items, and change the linkbutton's text according to menu's status at the same time, right?

Below is my test code, hope it helps:

<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" OnTreeNodeExpanded="TreeView1_TreeNodeExpanded" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" OnTreeNodeCollapsed="TreeView1_TreeNodeCollapsed" ShowLines="True">
                    </asp:TreeView>
                    <asp:LinkButton ID="lbClose" runat="server" OnClick="lbClose_Click">Close Menu</asp:LinkButton>

 

The codebehind of the linkbutton:

 protected void lbClose_Click(object sender, EventArgs e)
    {

        TreeNode tn = this.TreeView1.Nodes[0];
        if (tn.Expanded == true)
        {
            this.TreeView1.CollapseAll();

            this.lbClose.Text = "open Menu";
        }
        else
        {
            this.TreeView1.ExpandAll();

            this.lbClose.Text = "Close Menu";
        }
    }


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
rmdw
Asp.Net User
Re: Trying to get button to expand/collapse menu12/3/2007 5:48:47 PM

0/0

Thanks, Amanda.  Because of no response to this thread to date I posted the msg in another one.  In it, I eventually came up with an answer: http://forums.asp.net/p/1188354/2035485.aspx#2035485

P.S. In my testing I found that the nodes count = 0.  As such, the CollapseAll() didn't work, though surprisingly the ExpandAll() did.

Robert 


Robert Werner
Vancouver, BC
www.pocketpollster.com
Amanda Wang - M
Asp.Net User
Re: Trying to get button to expand/collapse menu12/4/2007 2:51:13 AM

0/0

Hi,

I use the TreeView1.Nodes[0] in oeder to find the root node, if you know what the root node is, you can use the findnode method, like below:

TreeNode tn = this.TreeView2.FindNode("Home");// The root node's text is Home

So you can adjust the status of the root, then expand/collapse menu control.

 protected void lbClose_Click(object sender, EventArgs e)
    {

    TreeNode tn = this.TreeView2.FindNode("Home");// find the root node of the treeview

        if (tn.Expanded == true)// adjust the rootnode whether is expanded
        {
            this.TreeView1.CollapseAll();

            this.lbClose.Text = "open Menu";
        }
        else
        {
            this.TreeView1.ExpandAll();

            this.lbClose.Text = "Close Menu";
        }
    }


Hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
rmdw
Asp.Net User
Re: Trying to get button to expand/collapse menu12/4/2007 6:28:39 AM

0/0

Amanda,

I'm glad it's working for you.  On my system, in the Click event, which occurs before the Data Binding, there are 0 nodes in the tree.  I'm guessing that you must be populating your tree in a different way.

I have a related question for you: Envision a tree in any state (ie. maybe all the nodes are closed, maybe they're all open, maybe some are open and some are closed).  This is the way the treeview, which serves as the menu on the left side of my master page works.  Now, when I jump from page to page to page, the tree always closes up again.  I'm not surprised, because the tree is being binded again.

But might you know a way around this so that it remains the same and thus provides a consistent appearance for the user?

Robert
 


Robert Werner
Vancouver, BC
www.pocketpollster.com
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Excel 2007 For Dummies Quick Reference: Quick Reference Authors: John Walkenbach, Colin Banfield, Pages: 224, Published: 2006
Macromedia Dreamweaver MX: Training from the Source Authors: Khristine Annwn Page, Pages: 549, Published: 2003
Dreamweaver 8: The Missing Manual Authors: David Sawyer McFarland, David Pogue, Pages: 936, Published: 2006
Special Edition Using Microsoft Office 2003, Student-Teacher Edition: Student-teacher Authors: Ed Bott, Woody Leonhard, Pages: 902, Published: 2006
Excel 2007 Advanced Report Development Authors: Timothy Zapawa, Pages: 542, Published: 2007
Microsoft Office 2003 All-in-one: All-in-one Authors: Joseph W. Habraken, Pages: 951, Published: 2004
Dreamweaver 8: The Missing Manual Authors: David Sawyer McFarland, David Pogue, Pages: 936, Published: 2006
Switching to the Mac: The Missing Manual Authors: David Pogue, Adam Goldstein, Pages: 508, Published: 2005
Foundation PHP for Dreamweaver 8 Authors: David Powers, Pages: 510, Published: 2005
Outlook 2003 Personal Trainer Authors: Inc, CustomGuide Inc, Michele Filshie, Pages: 320, Published: 2005

Web:
Trying to get button to expand/collapse menu
How Do I Create Collapse And Expand Menu In Javascript How Do I Create Collapse And Expand Menu In Javascript. Keep your Web site fast and well-structured with javascript rollover buttons links!
Help needed for a expand-collapse menu - bytes then the code for the text that pops up once the button is clicked is ... for the expand or collapse code to be run. Any help is apprieciated ...
Looking for TreeView Menu EXPAND / COLLAPSE ALL (How can i do it) Looking for TreeView Menu EXPAND / COLLAPSE ALL (How can i do it). Posted Date: 20 Oct 2004 Total Responses: 8 ...
Expand/Collapse Window + Nested Button - FlashMove Forum Expand/Collapse Window + Nested Button Flash MX 2004. ... that shows a very easily customizable expand/collapse menu for navigation. ...
BlogU: Expand/Collapse Sidebar Widget Title Jun 9, 2008 ... I spent about three days wondering how to expand/collapse my labels before I stumbled on your blog ..... Drop me a line. get an email button ...
JavaScript Tree Menu, Navigation Menu Tree, asp php tree menu Sothink Tree Menu, easy to build JavaScript tree menu. ... expanded/collapsed sub-trees; Easily expand/collapse sub-tree by clicking button, text or icon ...
Audacity: Audacity 1.3: Collapse/Expand Tracks Before clicking on the collapse button for the top track. After clicking on the collapse button. After selecting 'Collapse All Tracks' from the View menu ...
Flyspray:: Roadmap However, right now, many use the REC button to reactivate the player's backlight , ... FS#7515 - Radio disappears from menu! Expand Collapse: Over the past ...
Expand & Collapse Menu - WebDeveloper.com I'm trying to create an expand/collapse div menu like the one on http://www. bmwusa.com (bottom right corner, when page is loaded the button ...




Search This Site:










masterpage properties not accessable

treeview help!!

bug of treeview - child node could not expand after click on hyperlink of root node

treeview!

asp.net 2.0 menu control does not work if id starts with an underscore

menu control : cross page posting and posted values in nested controls?

export template

how do i make a master web control?

tree view based on database query...

menu control not working with master pages

display plus(+) and minus(-) sign for treenodes in a treeview in .net framework version 2.0

front controller

how to change the header falsh programmatically?

2 questions about menu css styles

master pages and images ...create a standard template over pages

masterpage.master does not exist but only on nlb

how to build navigation buttons that do not scroll with the rest of the page?

master page with selection from list to display selection details

web.sitemap url problem

how do i display empty nodes?

no build provider for .skin

menu control is sluggish in internet explorer, fast in firefox, opera

formating seperator in asp:menu

hello

looking for new fields in parent nodes of a sitemap

using cssfriendlyadapter, header menu dropdowns appears behind footer and detailsview

treeview mixed navigation in the master?

sitemappath & menu bar(navigation)

handle of applying css files

treeview and selected style

  Privacy | Contact Us
All Times Are GMT