Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Expand TreeView programmatically (ASP.NET 2.0)

Reply
Thread Tools

Expand TreeView programmatically (ASP.NET 2.0)

 
 
Karim El Jed
Guest
Posts: n/a
 
      10-05-2005
Hi,

I'm trying to expand a special Node of my TreeView from Codebehind.
I have a TreeView on a page for navigating to another site. On the other
tsite here is the same TreeView more precisely a new TreeView with the same
nodes
So I would like to keep the expanding state of the first Tree for the second
one on the next page. At least the last selected node (path will be saved in
query string) should be expanded.

Remarks: The TreeView is rendered in an IFrame to enable scrolling. Maybe
there might be another solution. Let me know if someone knows

Here is what I tried:

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
//Populate the Tree
TreeView1.Nodes.Add(TopicFactory.PopulateTopicTree Nodes());
TreeView1.Target = "_parent";

if (Request.QueryString["path"] != null)
{
//path for the node is in the query string
string path = Request.QueryString["path"];
TreeNode selected = TreeView1.FindNode(path);

if (selected != null)
{
//expand the node belonging to the given path
selected.Expand();
}
}
}
}

Finding the node is no problem. But it seems the method Expand() has no
effect

I hope someone can help.

Greetings

Karim


 
Reply With Quote
 
 
 
 
clintonG
Guest
Posts: n/a
 
      10-05-2005
Would this [1] help?
See also...
google: postbackurl site:msdn2.microsoft.com

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://msdn2.microsoft.com/en-us/lib...us,vs.80).aspx



"Karim El Jed" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I'm trying to expand a special Node of my TreeView from Codebehind.
> I have a TreeView on a page for navigating to another site. On the other
> tsite here is the same TreeView more precisely a new TreeView with the
> same nodes
> So I would like to keep the expanding state of the first Tree for the
> second one on the next page. At least the last selected node (path will be
> saved in query string) should be expanded.
>
> Remarks: The TreeView is rendered in an IFrame to enable scrolling. Maybe
> there might be another solution. Let me know if someone knows
>
> Here is what I tried:
>
> protected void Page_Load(object sender, EventArgs e)
> {
>
> if (!IsPostBack)
> {
> //Populate the Tree
> TreeView1.Nodes.Add(TopicFactory.PopulateTopicTree Nodes());
> TreeView1.Target = "_parent";
>
> if (Request.QueryString["path"] != null)
> {
> //path for the node is in the query string
> string path = Request.QueryString["path"];
> TreeNode selected = TreeView1.FindNode(path);
>
> if (selected != null)
> {
> //expand the node belonging to the given path
> selected.Expand();
> }
> }
> }
> }
>
> Finding the node is no problem. But it seems the method Expand() has no
> effect
>
> I hope someone can help.
>
> Greetings
>
> Karim
>



 
Reply With Quote
 
 
 
 
Karim El Jed
Guest
Posts: n/a
 
      10-06-2005
....no I don't think so. Problem is not to store and get the state of the
tree. Problem is that I cannot tell the Tree to expand a certain node.
This has to work even if the page is loaded for the first time. If I give a
path in the querystring the tree should expand this path.

Any other idea?


"clintonG" <(E-Mail Removed)> schrieb im
Newsbeitrag news:%(E-Mail Removed)...
> Would this [1] help?
> See also...
> google: postbackurl site:msdn2.microsoft.com
>
> <%= Clinton Gallagher
> METROmilwaukee (sm) "A Regional Information Service"
> NET csgallagher AT metromilwaukee.com
> URL http://metromilwaukee.com/
> URL http://clintongallagher.metromilwaukee.com/
>
> [1] http://msdn2.microsoft.com/en-us/lib...us,vs.80).aspx
>
>
>
> "Karim El Jed" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Hi,
>>
>> I'm trying to expand a special Node of my TreeView from Codebehind.
>> I have a TreeView on a page for navigating to another site. On the other
>> tsite here is the same TreeView more precisely a new TreeView with the
>> same nodes
>> So I would like to keep the expanding state of the first Tree for the
>> second one on the next page. At least the last selected node (path will
>> be saved in query string) should be expanded.
>>
>> Remarks: The TreeView is rendered in an IFrame to enable scrolling. Maybe
>> there might be another solution. Let me know if someone knows
>>
>> Here is what I tried:
>>
>> protected void Page_Load(object sender, EventArgs e)
>> {
>>
>> if (!IsPostBack)
>> {
>> //Populate the Tree
>> TreeView1.Nodes.Add(TopicFactory.PopulateTopicTree Nodes());
>> TreeView1.Target = "_parent";
>>
>> if (Request.QueryString["path"] != null)
>> {
>> //path for the node is in the query string
>> string path = Request.QueryString["path"];
>> TreeNode selected = TreeView1.FindNode(path);
>>
>> if (selected != null)
>> {
>> //expand the node belonging to the given path
>> selected.Expand();
>> }
>> }
>> }
>> }
>>
>> Finding the node is no problem. But it seems the method Expand() has no
>> effect
>>
>> I hope someone can help.
>>
>> Greetings
>>
>> Karim
>>

>
>



 
Reply With Quote
 
Patirck Ige
Guest
Posts: n/a
 
      10-07-2005
Have you done something similar using treeview v.1.1
Patrick


"Karim El Jed" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> ...no I don't think so. Problem is not to store and get the state of the
> tree. Problem is that I cannot tell the Tree to expand a certain node.
> This has to work even if the page is loaded for the first time. If I give

a
> path in the querystring the tree should expand this path.
>
> Any other idea?
>
>
> "clintonG" <(E-Mail Removed)> schrieb im
> Newsbeitrag news:%(E-Mail Removed)...
> > Would this [1] help?
> > See also...
> > google: postbackurl site:msdn2.microsoft.com
> >
> > <%= Clinton Gallagher
> > METROmilwaukee (sm) "A Regional Information Service"
> > NET csgallagher AT metromilwaukee.com
> > URL http://metromilwaukee.com/
> > URL http://clintongallagher.metromilwaukee.com/
> >
> > [1] http://msdn2.microsoft.com/en-us/lib...us,vs.80).aspx
> >
> >
> >
> > "Karim El Jed" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> Hi,
> >>
> >> I'm trying to expand a special Node of my TreeView from Codebehind.
> >> I have a TreeView on a page for navigating to another site. On the

other
> >> tsite here is the same TreeView more precisely a new TreeView with the
> >> same nodes
> >> So I would like to keep the expanding state of the first Tree for the
> >> second one on the next page. At least the last selected node (path will
> >> be saved in query string) should be expanded.
> >>
> >> Remarks: The TreeView is rendered in an IFrame to enable scrolling.

Maybe
> >> there might be another solution. Let me know if someone knows
> >>
> >> Here is what I tried:
> >>
> >> protected void Page_Load(object sender, EventArgs e)
> >> {
> >>
> >> if (!IsPostBack)
> >> {
> >> //Populate the Tree
> >> TreeView1.Nodes.Add(TopicFactory.PopulateTopicTree Nodes());
> >> TreeView1.Target = "_parent";
> >>
> >> if (Request.QueryString["path"] != null)
> >> {
> >> //path for the node is in the query string
> >> string path = Request.QueryString["path"];
> >> TreeNode selected = TreeView1.FindNode(path);
> >>
> >> if (selected != null)
> >> {
> >> //expand the node belonging to the given path
> >> selected.Expand();
> >> }
> >> }
> >> }
> >> }
> >>
> >> Finding the node is no problem. But it seems the method Expand() has no
> >> effect
> >>
> >> I hope someone can help.
> >>
> >> Greetings
> >>
> >> Karim
> >>

> >
> >

>
>



 
Reply With Quote
 
Karim El Jed
Guest
Posts: n/a
 
      10-07-2005
No, I didn't. I thought Treeview 1.1 only runs in IE, doesn't it?
I also tried to expand the Treenode before I add it to the Treeview but this
didn't work either.

Karim

"Patirck Ige" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Have you done something similar using treeview v.1.1
> Patrick
>
>
> "Karim El Jed" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> ...no I don't think so. Problem is not to store and get the state of the
>> tree. Problem is that I cannot tell the Tree to expand a certain node.
>> This has to work even if the page is loaded for the first time. If I give

> a
>> path in the querystring the tree should expand this path.
>>
>> Any other idea?
>>
>>
>> "clintonG" <(E-Mail Removed)> schrieb im
>> Newsbeitrag news:%(E-Mail Removed)...
>> > Would this [1] help?
>> > See also...
>> > google: postbackurl site:msdn2.microsoft.com
>> >
>> > <%= Clinton Gallagher
>> > METROmilwaukee (sm) "A Regional Information Service"
>> > NET csgallagher AT metromilwaukee.com
>> > URL http://metromilwaukee.com/
>> > URL http://clintongallagher.metromilwaukee.com/
>> >
>> > [1] http://msdn2.microsoft.com/en-us/lib...us,vs.80).aspx
>> >
>> >
>> >
>> > "Karim El Jed" <(E-Mail Removed)> wrote in message
>> > news:(E-Mail Removed)...
>> >> Hi,
>> >>
>> >> I'm trying to expand a special Node of my TreeView from Codebehind.
>> >> I have a TreeView on a page for navigating to another site. On the

> other
>> >> tsite here is the same TreeView more precisely a new TreeView with the
>> >> same nodes
>> >> So I would like to keep the expanding state of the first Tree for the
>> >> second one on the next page. At least the last selected node (path
>> >> will
>> >> be saved in query string) should be expanded.
>> >>
>> >> Remarks: The TreeView is rendered in an IFrame to enable scrolling.

> Maybe
>> >> there might be another solution. Let me know if someone knows
>> >>
>> >> Here is what I tried:
>> >>
>> >> protected void Page_Load(object sender, EventArgs e)
>> >> {
>> >>
>> >> if (!IsPostBack)
>> >> {
>> >> //Populate the Tree
>> >> TreeView1.Nodes.Add(TopicFactory.PopulateTopicTree Nodes());
>> >> TreeView1.Target = "_parent";
>> >>
>> >> if (Request.QueryString["path"] != null)
>> >> {
>> >> //path for the node is in the query string
>> >> string path = Request.QueryString["path"];
>> >> TreeNode selected = TreeView1.FindNode(path);
>> >>
>> >> if (selected != null)
>> >> {
>> >> //expand the node belonging to the given path
>> >> selected.Expand();
>> >> }
>> >> }
>> >> }
>> >> }
>> >>
>> >> Finding the node is no problem. But it seems the method Expand() has
>> >> no
>> >> effect
>> >>
>> >> I hope someone can help.
>> >>
>> >> Greetings
>> >>
>> >> Karim
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Maintaining treeview expand collapse status per node? Edwin Knoppert ASP .Net 1 11-09-2005 03:09 PM
Expand TreeView programmatically (ASP.NET 2.0) Karim El Jed ASP .Net Web Controls 0 10-06-2005 12:35 PM
asp.net 2.0 treeview control expand with select Stephen ASP .Net 2 08-24-2005 03:07 PM
Expand Treeview =?Utf-8?B?SHV0dHk=?= ASP .Net 5 01-14-2005 02:55 PM
urgent please : treeview control expand collapse Gönen EREN ASP .Net 4 08-16-2003 06:15 PM



Advertisments