|
 |
aspx_beginners thread: Urgent Help needed with Treeview Control
Message #1 by "Sri Vidya" <svsvidya@i...> on Thu, 01 Aug 2002 15:41:08 +0530
|
|
Hi All,
Here is a simple piece of code using the TREEVIEW control. I would
like to know why the OnSelectedIndexChanged event fails to return any
data.
Any help will be greatly appreciated. Need it very badly.
Just copy this code to a .aspx file and execute in browser. Click on
any node on the treeview control, if it works, then there should be an
entry below the text called EVENT LOG indicating which was the OLDNODE
and which is the current NEWNODE.
I am using IE 6.0 version to execute this file.
Thanks in advance.
Cheers,
Vidya.
=======================================================================
<%@ Import Namespace="Microsoft.Web.UI.WebControls" %>
<%@ Register TagPrefix="mytree"
Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.116,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<html>
<script runat="server">
Sub OnSelectedIndexChanged(sender as Object, e as
TreeViewSelectEventArgs)
Response.Write (" Hi" )
myLabel.Text += "<BR> Selected = " & e.NewNode.ToString() & "
(OldNode Index = " + e.OldNode.ToString() + ")"
End Sub
</script>
<head>
</head>
<body>
<h3> <font face="Arial"> Treeview Control demo </font> </h3>
<form runat="server">
<mytree:TreeView runat="server" AutoPostBack="true"
DefaultStyle="font-name:Verdana;font-size:12pt;color:black;"
SelectedStyle="font-name:Verdana;font-size:12pt;color:red;"
OnSelectedIndexChanged="OnSelectedIndexChanged" >
<mytree:treenode text="Asia" >
<mytree:treenode text="China" />
<mytree:treenode text="India" />
</mytree:treenode>
<mytree:treenode text="Africa">
<mytree:treenode text="Zaire" />
<mytree:treenode text="Zambia" />
</mytree:treenode>
<mytree:treenode text="North America">
<mytree:treenode text="Canada" />
<mytree:treenode text="United States" />
</mytree:treenode>
</mytree:treeview>
<br>
<asp:label id="myLabel" runat="server"> Event Log: </asp:label>
</form>
</body>
</html>
======================================================================
---------------------------------------------
http://mail.indiainfo.com
India's first ISO certified portal
Check world time at http://time.indiainfo.com
Message #2 by Elissa Setarehshenas <elissasetareh@y...> on Thu, 1 Aug 2002 06:09:52 -0700 (PDT)
|
|
Vidya,
All e.NewNode.ToString() will return to you is the
node number of the item you selected( if you slected
United States all you will get is 2.1) To get at the
text attribute use
TreeView1.GetNodeFromIndex(e.NewNode).Text
If you want to get the ID attribute(which you're not
using now but might want to in the future it comes in
very handy if you want to store more information about
a node) use
TreeView1.GetNodeFromIndex(e.OldNode).ID
--- Sri Vidya <svsvidya@i...> wrote:
> Hi All,
>
> Here is a simple piece of code using the TREEVIEW
> control. I would
> like to know why the OnSelectedIndexChanged event
> fails to return any
> data.
>
> Any help will be greatly appreciated. Need it very
> badly.
>
> Just copy this code to a .aspx file and execute in
> browser. Click on
> any node on the treeview control, if it works, then
> there should be an
> entry below the text called EVENT LOG indicating
> which was the OLDNODE
> and which is the current NEWNODE.
>
> I am using IE 6.0 version to execute this file.
>
> Thanks in advance.
>
> Cheers,
> Vidya.
>
>
>
=======================================================================
>
> <%@ Import Namespace="Microsoft.Web.UI.WebControls"
> %>
> <%@ Register TagPrefix="mytree"
> Namespace="Microsoft.Web.UI.WebControls"
> Assembly="Microsoft.Web.UI.WebControls,
> Version=1.0.2.116,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
>
> <html>
> <script runat="server">
> Sub OnSelectedIndexChanged(sender as Object, e as
> TreeViewSelectEventArgs)
> Response.Write (" Hi" )
> myLabel.Text += "<BR> Selected = " &
> e.NewNode.ToString() & "
> (OldNode Index = " + e.OldNode.ToString() + ")"
> End Sub
>
> </script>
>
> <head>
> </head>
> <body>
> <h3> <font face="Arial"> Treeview Control demo
> </font> </h3>
> <form runat="server">
>
> <mytree:TreeView runat="server" AutoPostBack="true"
>
DefaultStyle="font-name:Verdana;font-size:12pt;color:black;"
>
>
SelectedStyle="font-name:Verdana;font-size:12pt;color:red;"
>
> OnSelectedIndexChanged="OnSelectedIndexChanged" >
>
> <mytree:treenode text="Asia" >
> <mytree:treenode text="China" />
> <mytree:treenode text="India" />
> </mytree:treenode>
>
> <mytree:treenode text="Africa">
> <mytree:treenode text="Zaire" />
> <mytree:treenode text="Zambia" />
> </mytree:treenode>
>
> <mytree:treenode text="North America">
> <mytree:treenode text="Canada" />
> <mytree:treenode text="United States" />
> </mytree:treenode>
>
> </mytree:treeview>
> <br>
> <asp:label id="myLabel" runat="server"> Event Log:
> </asp:label>
> </form>
> </body>
> </html>
>
======================================================================
> ---------------------------------------------
> http://mail.indiainfo.com
> India's first ISO certified portal
> Check world time at http://time.indiainfo.com
>
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
Message #3 by "Robert Sindall" <rsindall@z...> on Thu, 1 Aug 2002 18:56:42 +0100
|
|
Hi
I think you need
Treeview.SelectedNodeIndex.ToString() ' Returns the selected index
Treeview.GetNodeFromIndex(Treeview.SelectedNodeIndex.ToString()).FindNodeAtt
ribute("NodeData") ' finds items on the tree..
-----Original Message-----
From: Elissa Setarehshenas [mailto:elissasetareh@y...]
Sent: 01 August 2002 14:10
To: aspx_beginners
Subject: [aspx_beginners] Re: Urgent Help needed with Treeview Control
Vidya,
All e.NewNode.ToString() will return to you is the
node number of the item you selected( if you slected
United States all you will get is 2.1) To get at the
text attribute use
TreeView1.GetNodeFromIndex(e.NewNode).Text
If you want to get the ID attribute(which you're not
using now but might want to in the future it comes in
very handy if you want to store more information about
a node) use
TreeView1.GetNodeFromIndex(e.OldNode).ID
--- Sri Vidya <svsvidya@i...> wrote:
> Hi All,
>
> Here is a simple piece of code using the TREEVIEW
> control. I would
> like to know why the OnSelectedIndexChanged event
> fails to return any
> data.
>
> Any help will be greatly appreciated. Need it very
> badly.
>
> Just copy this code to a .aspx file and execute in
> browser. Click on
> any node on the treeview control, if it works, then
> there should be an
> entry below the text called EVENT LOG indicating
> which was the OLDNODE
> and which is the current NEWNODE.
>
> I am using IE 6.0 version to execute this file.
>
> Thanks in advance.
>
> Cheers,
> Vidya.
>
>
>
=======================================================================
>
> <%@ Import Namespace="Microsoft.Web.UI.WebControls"
> %>
> <%@ Register TagPrefix="mytree"
> Namespace="Microsoft.Web.UI.WebControls"
> Assembly="Microsoft.Web.UI.WebControls,
> Version=1.0.2.116,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
>
> <html>
> <script runat="server">
> Sub OnSelectedIndexChanged(sender as Object, e as
> TreeViewSelectEventArgs)
> Response.Write (" Hi" )
> myLabel.Text += "<BR> Selected = " &
> e.NewNode.ToString() & "
> (OldNode Index = " + e.OldNode.ToString() + ")"
> End Sub
>
> </script>
>
> <head>
> </head>
> <body>
> <h3> <font face="Arial"> Treeview Control demo
> </font> </h3>
> <form runat="server">
>
> <mytree:TreeView runat="server" AutoPostBack="true"
>
DefaultStyle="font-name:Verdana;font-size:12pt;color:black;"
>
>
SelectedStyle="font-name:Verdana;font-size:12pt;color:red;"
>
> OnSelectedIndexChanged="OnSelectedIndexChanged" >
>
> <mytree:treenode text="Asia" >
> <mytree:treenode text="China" />
> <mytree:treenode text="India" />
> </mytree:treenode>
>
> <mytree:treenode text="Africa">
> <mytree:treenode text="Zaire" />
> <mytree:treenode text="Zambia" />
> </mytree:treenode>
>
> <mytree:treenode text="North America">
> <mytree:treenode text="Canada" />
> <mytree:treenode text="United States" />
> </mytree:treenode>
>
> </mytree:treeview>
> <br>
> <asp:label id="myLabel" runat="server"> Event Log:
> </asp:label>
> </form>
> </body>
> </html>
>
======================================================================
> ---------------------------------------------
> http://mail.indiainfo.com
> India's first ISO certified portal
> Check world time at http://time.indiainfo.com
>
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
Message #4 by "Sri Vidya" <svsvidya@i...> on Fri, 02 Aug 2002 09:35:13 +0530
|
|
Hi Elissa, Robert,
Thanks a ton for the reply. Although what you guys have written is
true, my problem is that the OnSelectedIndexChanged Event does not get
triggered (when I click any node) at all on my system (for the code
example I had pasted earlier). I would like to know what could be the
reason.
Any guess or help is what I need now.
Thanks.
Vidya.
On Thu, 1 Aug 2002 18:56:42 +0100
"Robert Sindall" <rsindall@z...> wrote:
>Hi
>
>I think you need
>
>Treeview.SelectedNodeIndex.ToString() ' Returns the selected index
>
>
>Treeview.GetNodeFromIndex(Treeview.SelectedNodeIndex.ToString()).FindNodeAtt
>ribute("NodeData") ' finds items on the tree..
>
>-----Original Message-----
>From: Elissa Setarehshenas [mailto:elissasetareh@y...]
>Sent: 01 August 2002 14:10
>To: aspx_beginners
>Subject: [aspx_beginners] Re: Urgent Help needed with Treeview
>Control
>
>
>Vidya,
>All e.NewNode.ToString() will return to you is the
>node number of the item you selected( if you slected
>United States all you will get is 2.1) To get at the
>text attribute use
>TreeView1.GetNodeFromIndex(e.NewNode).Text
>
>If you want to get the ID attribute(which you're not
>using now but might want to in the future it comes in
>very handy if you want to store more information about
>a node) use
>TreeView1.GetNodeFromIndex(e.OldNode).ID
>
>--- Sri Vidya <svsvidya@i...> wrote:
>> Hi All,
>>
>> Here is a simple piece of code using the TREEVIEW
>> control. I would
>> like to know why the OnSelectedIndexChanged event
>> fails to return any
>> data.
>>
>> Any help will be greatly appreciated. Need it very
>> badly.
>>
>> Just copy this code to a .aspx file and execute in
>> browser. Click on
>> any node on the treeview control, if it works, then
>> there should be an
>> entry below the text called EVENT LOG indicating
>> which was the OLDNODE
>> and which is the current NEWNODE.
>>
>> I am using IE 6.0 version to execute this file.
>>
>> Thanks in advance.
>>
>> Cheers,
>> Vidya.
>>
>>
>>
>=======================================================================
>>
>> <%@ Import Namespace="Microsoft.Web.UI.WebControls"
>> %>
>> <%@ Register TagPrefix="mytree"
>> Namespace="Microsoft.Web.UI.WebControls"
>> Assembly="Microsoft.Web.UI.WebControls,
>> Version=1.0.2.116,
>> Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
>>
>> <html>
>> <script runat="server">
>> Sub OnSelectedIndexChanged(sender as Object, e as
>> TreeViewSelectEventArgs)
>> Response.Write (" Hi" )
>> myLabel.Text += "<BR> Selected = " &
>> e.NewNode.ToString() & "
>> (OldNode Index = " + e.OldNode.ToString() + ")"
>> End Sub
>>
>> </script>
>>
>> <head>
>> </head>
>> <body>
>> <h3> <font face="Arial"> Treeview Control demo
>> </font> </h3>
>> <form runat="server">
>>
>> <mytree:TreeView runat="server" AutoPostBack="true"
>>
>DefaultStyle="font-name:Verdana;font-size:12pt;color:black;"
>>
>>
>SelectedStyle="font-name:Verdana;font-size:12pt;color:red;"
>>
>> OnSelectedIndexChanged="OnSelectedIndexChanged" >
>>
>> <mytree:treenode text="Asia" >
>> <mytree:treenode text="China" />
>> <mytree:treenode text="India" />
>> </mytree:treenode>
>>
>> <mytree:treenode text="Africa">
>> <mytree:treenode text="Zaire" />
>> <mytree:treenode text="Zambia" />
>> </mytree:treenode>
>>
>> <mytree:treenode text="North America">
>> <mytree:treenode text="Canada" />
>> <mytree:treenode text="United States" />
>> </mytree:treenode>
>>
>> </mytree:treeview>
>> <br>
>> <asp:label id="myLabel" runat="server"> Event Log:
>> </asp:label>
>> </form>
>> </body>
>> </html>
>>
>======================================================================
>> ---------------------------------------------
>> http://mail.indiainfo.com
>> India's first ISO certified portal
>> Check world time at http://time.indiainfo.com
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Health - Feel better, live better
>http://health.yahoo.com
>
>
>
>
---------------------------------------------
http://mail.indiainfo.com
India's first ISO certified portal
Check world time at http://time.indiainfo.com
Message #5 by "Robert Sindall" <rsindall@z...> on Fri, 2 Aug 2002 10:00:06 +0100
|
|
How about:
use this in your vb and don't bother with the ASP:
OnSelectedIndexChanged="function()"
Private Function this() Handles SecurityTree.SelectedIndexChange
End Function
-----Original Message-----
From: Sri Vidya [mailto:svsvidya@i...]
Sent: 02 August 2002 05:05
To: aspx_beginners
Subject: [aspx_beginners] Re: Urgent Help needed with Treeview Control
Hi Elissa, Robert,
Thanks a ton for the reply. Although what you guys have written is
true, my problem is that the OnSelectedIndexChanged Event does not get
triggered (when I click any node) at all on my system (for the code
example I had pasted earlier). I would like to know what could be the
reason.
Any guess or help is what I need now.
Thanks.
Vidya.
On Thu, 1 Aug 2002 18:56:42 +0100
"Robert Sindall" <rsindall@z...> wrote:
>Hi
>
>I think you need
>
>Treeview.SelectedNodeIndex.ToString() ' Returns the selected index
>
>
>Treeview.GetNodeFromIndex(Treeview.SelectedNodeIndex.ToString()).FindNodeAt
t
>ribute("NodeData") ' finds items on the tree..
>
>-----Original Message-----
>From: Elissa Setarehshenas [mailto:elissasetareh@y...]
>Sent: 01 August 2002 14:10
>To: aspx_beginners
>Subject: [aspx_beginners] Re: Urgent Help needed with Treeview
>Control
>
>
>Vidya,
>All e.NewNode.ToString() will return to you is the
>node number of the item you selected( if you slected
>United States all you will get is 2.1) To get at the
>text attribute use
>TreeView1.GetNodeFromIndex(e.NewNode).Text
>
>If you want to get the ID attribute(which you're not
>using now but might want to in the future it comes in
>very handy if you want to store more information about
>a node) use
>TreeView1.GetNodeFromIndex(e.OldNode).ID
>
>--- Sri Vidya <svsvidya@i...> wrote:
>> Hi All,
>>
>> Here is a simple piece of code using the TREEVIEW
>> control. I would
>> like to know why the OnSelectedIndexChanged event
>> fails to return any
>> data.
>>
>> Any help will be greatly appreciated. Need it very
>> badly.
>>
>> Just copy this code to a .aspx file and execute in
>> browser. Click on
>> any node on the treeview control, if it works, then
>> there should be an
>> entry below the text called EVENT LOG indicating
>> which was the OLDNODE
>> and which is the current NEWNODE.
>>
>> I am using IE 6.0 version to execute this file.
>>
>> Thanks in advance.
>>
>> Cheers,
>> Vidya.
>>
>>
>>
>=======================================================================
>>
>> <%@ Import Namespace="Microsoft.Web.UI.WebControls"
>> %>
>> <%@ Register TagPrefix="mytree"
>> Namespace="Microsoft.Web.UI.WebControls"
>> Assembly="Microsoft.Web.UI.WebControls,
>> Version=1.0.2.116,
>> Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
>>
>> <html>
>> <script runat="server">
>> Sub OnSelectedIndexChanged(sender as Object, e as
>> TreeViewSelectEventArgs)
>> Response.Write (" Hi" )
>> myLabel.Text += "<BR> Selected = " &
>> e.NewNode.ToString() & "
>> (OldNode Index = " + e.OldNode.ToString() + ")"
>> End Sub
>>
>> </script>
>>
>> <head>
>> </head>
>> <body>
>> <h3> <font face="Arial"> Treeview Control demo
>> </font> </h3>
>> <form runat="server">
>>
>> <mytree:TreeView runat="server" AutoPostBack="true"
>>
>DefaultStyle="font-name:Verdana;font-size:12pt;color:black;"
>>
>>
>SelectedStyle="font-name:Verdana;font-size:12pt;color:red;"
>>
>> OnSelectedIndexChanged="OnSelectedIndexChanged" >
>>
>> <mytree:treenode text="Asia" >
>> <mytree:treenode text="China" />
>> <mytree:treenode text="India" />
>> </mytree:treenode>
>>
>> <mytree:treenode text="Africa">
>> <mytree:treenode text="Zaire" />
>> <mytree:treenode text="Zambia" />
>> </mytree:treenode>
>>
>> <mytree:treenode text="North America">
>> <mytree:treenode text="Canada" />
>> <mytree:treenode text="United States" />
>> </mytree:treenode>
>>
>> </mytree:treeview>
>> <br>
>> <asp:label id="myLabel" runat="server"> Event Log:
>> </asp:label>
>> </form>
>> </body>
>> </html>
>>
>======================================================================
>> ---------------------------------------------
>> http://mail.indiainfo.com
>> India's first ISO certified portal
>> Check world time at http://time.indiainfo.com
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Health - Feel better, live better
>http://health.yahoo.com
>
>
>
>
---------------------------------------------
http://mail.indiainfo.com
India's first ISO certified portal
Check world time at http://time.indiainfo.com
Message #6 by Elissa Setarehshenas <elissasetareh@y...> on Mon, 5 Aug 2002 05:38:42 -0700 (PDT)
|
|
Vidya,
Did you set autopostback=true. If you don't the tree
wont respond to any events
--- Sri Vidya <svsvidya@i...> wrote:
> Hi Elissa, Robert,
>
> Thanks a ton for the reply. Although what you guys
> have written is
> true, my problem is that the OnSelectedIndexChanged
> Event does not get
> triggered (when I click any node) at all on my
> system (for the code
> example I had pasted earlier). I would like to know
> what could be the
> reason.
>
> Any guess or help is what I need now.
>
> Thanks.
> Vidya.
>
>
>
>
>
> On Thu, 1 Aug 2002 18:56:42 +0100
> "Robert Sindall" <rsindall@z...> wrote:
> >Hi
> >
> >I think you need
> >
> >Treeview.SelectedNodeIndex.ToString() ' Returns the
> selected index
> >
> >
>
>Treeview.GetNodeFromIndex(Treeview.SelectedNodeIndex.ToString()).FindNodeAtt
> >ribute("NodeData") ' finds items on the tree..
> >
> >-----Original Message-----
> >From: Elissa Setarehshenas
> [mailto:elissasetareh@y...]
> >Sent: 01 August 2002 14:10
> >To: aspx_beginners
> >Subject: [aspx_beginners] Re: Urgent Help needed
> with Treeview
> >Control
> >
> >
> >Vidya,
> >All e.NewNode.ToString() will return to you is the
> >node number of the item you selected( if you
> slected
> >United States all you will get is 2.1) To get at
> the
> >text attribute use
> >TreeView1.GetNodeFromIndex(e.NewNode).Text
> >
> >If you want to get the ID attribute(which you're
> not
> >using now but might want to in the future it comes
> in
> >very handy if you want to store more information
> about
> >a node) use
> >TreeView1.GetNodeFromIndex(e.OldNode).ID
> >
> >--- Sri Vidya <svsvidya@i...> wrote:
> >> Hi All,
> >>
> >> Here is a simple piece of code using the TREEVIEW
> >> control. I would
> >> like to know why the OnSelectedIndexChanged event
> >> fails to return any
> >> data.
> >>
> >> Any help will be greatly appreciated. Need it
> very
> >> badly.
> >>
> >> Just copy this code to a .aspx file and execute
> in
> >> browser. Click on
> >> any node on the treeview control, if it works,
> then
> >> there should be an
> >> entry below the text called EVENT LOG indicating
> >> which was the OLDNODE
> >> and which is the current NEWNODE.
> >>
> >> I am using IE 6.0 version to execute this file.
> >>
> >> Thanks in advance.
> >>
> >> Cheers,
> >> Vidya.
> >>
> >>
> >>
>
>=======================================================================
> >>
> >> <%@ Import
> Namespace="Microsoft.Web.UI.WebControls"
> >> %>
> >> <%@ Register TagPrefix="mytree"
> >> Namespace="Microsoft.Web.UI.WebControls"
> >> Assembly="Microsoft.Web.UI.WebControls,
> >> Version=1.0.2.116,
> >> Culture=neutral, PublicKeyToken=31bf3856ad364e35"
> %>
> >>
> >> <html>
> >> <script runat="server">
> >> Sub OnSelectedIndexChanged(sender as Object, e as
> >> TreeViewSelectEventArgs)
> >> Response.Write (" Hi" )
> >> myLabel.Text += "<BR> Selected = " &
> >> e.NewNode.ToString() & "
> >> (OldNode Index = " + e.OldNode.ToString() + ")"
> >> End Sub
> >>
> >> </script>
> >>
> >> <head>
> >> </head>
> >> <body>
> >> <h3> <font face="Arial"> Treeview Control demo
> >> </font> </h3>
> >> <form runat="server">
> >>
> >> <mytree:TreeView runat="server"
> AutoPostBack="true"
> >>
>
>DefaultStyle="font-name:Verdana;font-size:12pt;color:black;"
> >>
> >>
>
>SelectedStyle="font-name:Verdana;font-size:12pt;color:red;"
> >>
> >> OnSelectedIndexChanged="OnSelectedIndexChanged" >
> >>
> >> <mytree:treenode text="Asia" >
> >> <mytree:treenode text="China" />
> >> <mytree:treenode text="India" />
> >> </mytree:treenode>
> >>
> >> <mytree:treenode text="Africa">
> >> <mytree:treenode text="Zaire" />
> >> <mytree:treenode text="Zambia" />
> >> </mytree:treenode>
> >>
> >> <mytree:treenode text="North America">
> >> <mytree:treenode text="Canada" />
> >> <mytree:treenode text="United States" />
> >> </mytree:treenode>
> >>
> >> </mytree:treeview>
> >> <br>
> >> <asp:label id="myLabel" runat="server"> Event
> Log:
> >> </asp:label>
> >> </form>
> >> </body>
> >> </html>
> >>
>
>======================================================================
> >> ---------------------------------------------
> >> http://mail.indiainfo.com
> >> India's first ISO certified portal
> >> Check world time at http://time.indiainfo.com
> >>
> >
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Yahoo! Health - Feel better, live better
> >http://health.yahoo.com
> >
> >
> >
> >
>
> ---------------------------------------------
> http://mail.indiainfo.com
> India's first ISO certified portal
> Check world time at http://time.indiainfo.com
>
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
|
|
 |