TreeView and Master Pages

G

Guest

I need to know how to maintain de status (nodes expanded and selected) of a
treeview in a master page.

I have a master page with a treeview. I have a default page, when the
treeview is expanded and a node is selected then redirects to a another page

Response.Redirect("Page2.aspx")

And run's ok, but the treeview in this page is colapsed. The treeview
maintain its aspect, the images for the nodes, etc, but is colapsed and
nothing node is selected

Many thanks for your help
 
S

S. Justin Gengo

Juanjo,

Store the selected node number in viewstate and on page loads check that
viewstate parameter and if a selected node exists set the treeview to
display it as selected.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
G

Guest

OK Justin,

I do it.

In the master page code

Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles TreeView1.SelectedNodeChanged

ViewState("SelectedNode") = TreeView1.SelectedNode.Value
Response.Redirect("Page2.aspx")

End Sub



And in the Page2_Load

If Me.ViewState("SelectedNode").ToString = "Perfiles" Then

'Code for selected node

End If

But now the problem is that ViewState("SelectedNode") is nothing. Not exists

What I'm doing wrong?
 
S

S. Justin Gengo

Juanjo,

A response.redirect clears the viewstate. Either store the parameter in a
session variable (if that will be allright for your application) or use
Server.Transfer and store the value in a context variable instead. If you
need any clarification on how session variables or server.transfer and the
context object works let me know.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
G

Guest

OK, thanx

Exists another way to load the page2.aspx without response.redirect command?

I'm a newbie in asp.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top