Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Treeview Not Shown
Message
De
24/12/2009 20:25:02
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
À
24/12/2009 18:27:47
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01440585
Message ID:
01440600
Vues:
27
>>>Revisiting this issue. Hope somebody can point out the error in my code.
>>>
>>>I have a Master Page which has a Treeview control on it.
>>>
>>>Protected Sub MasterPage_Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
>>>       Handles Me.Load
>>>    If Not IsPostBack Then
>>>        If Session("Treeview") Is Nothing Then
>>>            .
>>>            .
>>>            Build the treeview
>>>            .
>>>            .
>>>
>>>            Session.Add("Treeview", TreeView1)
>>>
>>>        Else
>>>            TreeView1 = CType(Session("Treeview"), TreeView)
>>>        End If
>>>    End If
>>>End Sub
>>>
>>>
>>>Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As TreeView, ByVal e As System.EventArgs)
>>>      Handles TreeView1.SelectedNodeChanged
>>>
>>>    Session("Treeview") = TreeView1
>>>    Select Case sender.SelectedNode.Value
>>>        Case 1
>>>            Response.Redirect("contentpage1.aspx")
>>>        Case 2
>>>            Response.Redirect("contentpage2.aspx")
>>>        Case 3
>>>            Response.Redirect("contentpage3.aspx")
>>>        etc.
>>>    End Select
>>>End Sub
>>>
>>>The problem is that when I click on one of the Treview nodes, the treeview disappears when the ContentPage is displayed.
>>>
>>>What I am trying to do is have the Treeview appear in the same state as when clicked (with the nodes expanded, etc).
>>>
>>>Question 1: Is Response.Redirect the correct way to call the ContentPage?
>>>
>>>Question 2: Is it correct to save the Treeview in the Session? 2A: Am I doing that properly
>>>
>>>Question 3: Should I be doing something in the ContentPage to restore the Treeview?
>>>
>>>FWIW......Here is the sequence of events when I click on one of the nodes
>>>MasterPage_Page_Load                 IsPostBack = TRUE
>>>Treeview_SelectedNodeChanged
>>>ContentPage_Page_Load               IsPostBack = FALSE
>>>MasterPage_Page_Load                IsPostBack = FALSE
>>>
>>>Other than trying to move from VFP to .NET < VBG >........could somebody point out the error of my ways here????
>>>
>>>All responses greatly appreciated...........Rich
>>
>>Have you tried just taking the test for isPostback out of your load event? It looks like you are testing if the treeview is in the session or not and building it, but when postback is true, you don't do anything. No treeview. I would think another approach would be to not store the treeview in session but store its state in some fashion. Just a thought.
>>Tim
>
>Thanks for taking the time to respond.
>
>My understanding is that if IsPostBack is TRUE, then the treeview already exists and doesn't need to be rebuilt.
>
>The event sequence also seems to indicate that the final Page_Load goes through the rebuild of the Treeview. When I traced it, the code goes to the ELSE section and gets it out of the Session.
>
>Looking in the debugger, it also shows
>
>Treeview1.visible = TRUE
>
>but, unfortunately, it doesn't appear anywhere on the screen.
>
>.......Rich

Is ViewState enabled on the TreeView control?

Also, as an aside, is this for a sitemap or something?
Very fitting: http://xkcd.com/386/
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform