TreeView SelectedNodeChanged Event

  • Thread starter Andrew Robinson
  • Start date
A

Andrew Robinson

I am using a TreeView to perform navigation and have a few nodes that need
to generate a popup menu. For this, I use the SelectedNodeChanged event and
then add the relevant "window.open" script to the page using the
ClientScript.RegisterStartupScript method.

This seems to work fine, but if the user clicks on the same node twice, the
event doesn't fire a second time. I assume this is by design as the Node
Selection hasn't changed, but anyone know of a way to clear the selection
without clearing all of the nodes on the TreeView and repopulating them?


Thanks,


Andrew
 
S

Steven Cheng[MSFT]

Hi Andrew,

Welcome to ASPNET newsgroup.
Regarding on the TreeView Control's SelectedNodeChanged event, based on my
research, it is only working when a certain node is not selected. After it
is selected, we can not make it fire again if we haven't changed selected
node between the multiple selecting.... Also, seems the current TreeView
control dosn't support define custom ItemTemplate... And I'm not sure
whether the Menu Control can be an alternative approach for your scenario?
The ASP.NET 2.0 Menu control can let us define Menu Item template for
static and dynamic menu items, so that different kinds of controls can
appear when menu displayed. For example:

<asp:Menu ID="Menu1" runat="server" >
<StaticItemTemplate>
<asp:LinkButton ID="LinkButton3"
runat="server">LinkButton</asp:LinkButton>
</StaticItemTemplate>
<DynamicItemTemplate>
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</DynamicItemTemplate>


Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)








--------------------
| From: "Andrew Robinson" <[email protected]>
| Subject: TreeView SelectedNodeChanged Event
| Date: Mon, 5 Dec 2005 11:06:01 -0800
| Lines: 17
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <ugjvv7c#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 216.57.203.121
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:362835
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I am using a TreeView to perform navigation and have a few nodes that
need
| to generate a popup menu. For this, I use the SelectedNodeChanged event
and
| then add the relevant "window.open" script to the page using the
| ClientScript.RegisterStartupScript method.
|
| This seems to work fine, but if the user clicks on the same node twice,
the
| event doesn't fire a second time. I assume this is by design as the Node
| Selection hasn't changed, but anyone know of a way to clear the selection
| without clearing all of the nodes on the TreeView and repopulating them?
|
|
| Thanks,
|
|
| Andrew
|
|
|
 
A

Andrew Robinson

Steve,

Not sure why you talking about a template? what would that accomplish or
solve?

Is there any way of changing the selected node between postbacks?

Thanks,

-Andrew
 
A

Andrew Robinson

Ok, I answered my own question:

TreeView1.SelectedNode.Selected = false;

This is what I was looking for.

-Andrew
 
S

Steven Cheng[MSFT]

Thanks for your response Andrew,

I mentioned template in Menu since that can help us define some html
template (such as <div> ) and registering clientscript for dynamically
show/ hide layer ..... at clientside.. And TreeView is limited on such
functionality. Anyway, glad that you've found the things you looking for...


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| From: "Andrew Robinson" <[email protected]>
| References: <ugjvv7c#[email protected]>
<5tBtIkk#[email protected]>
<u5MmnJo#[email protected]>
| Subject: Re: TreeView SelectedNodeChanged Event
| Date: Tue, 6 Dec 2005 11:06:14 -0800
| Lines: 113
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Response
| Message-ID: <uTYBigp#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 216.57.203.121
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:363163
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Ok, I answered my own question:
|
| TreeView1.SelectedNode.Selected = false;
|
| This is what I was looking for.
|
| -Andrew
|
| | > Steve,
| >
| > Not sure why you talking about a template? what would that accomplish
or
| > solve?
| >
| > Is there any way of changing the selected node between postbacks?
| >
| > Thanks,
| >
| > -Andrew
| >
| > | >> Hi Andrew,
| >>
| >> Welcome to ASPNET newsgroup.
| >> Regarding on the TreeView Control's SelectedNodeChanged event, based
on
| >> my
| >> research, it is only working when a certain node is not selected.
After
| >> it
| >> is selected, we can not make it fire again if we haven't changed
selected
| >> node between the multiple selecting.... Also, seems the current
| >> TreeView
| >> control dosn't support define custom ItemTemplate... And I'm not sure
| >> whether the Menu Control can be an alternative approach for your
| >> scenario?
| >> The ASP.NET 2.0 Menu control can let us define Menu Item template for
| >> static and dynamic menu items, so that different kinds of controls can
| >> appear when menu displayed. For example:
| >>
| >> <asp:Menu ID="Menu1" runat="server" >
| >> <StaticItemTemplate>
| >> <asp:LinkButton ID="LinkButton3"
| >> runat="server">LinkButton</asp:LinkButton>
| >> </StaticItemTemplate>
| >> <DynamicItemTemplate>
| >> <asp:Calendar ID="Calendar1"
runat="server"></asp:Calendar>
| >> </DynamicItemTemplate>
| >>
| >>
| >> Thanks,
| >>
| >> Steven Cheng
| >> Microsoft Online Support
| >>
| >> Get Secure! www.microsoft.com/security
| >> (This posting is provided "AS IS", with no warranties, and confers no
| >> rights.)
| >>
| >>
| >>
| >>
| >>
| >>
| >>
| >>
| >> --------------------
| >> | From: "Andrew Robinson" <[email protected]>
| >> | Subject: TreeView SelectedNodeChanged Event
| >> | Date: Mon, 5 Dec 2005 11:06:01 -0800
| >> | Lines: 17
| >> | X-Priority: 3
| >> | X-MSMail-Priority: Normal
| >> | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| >> | X-RFC2646: Format=Flowed; Original
| >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| >> | Message-ID: <ugjvv7c#[email protected]>
| >> | Newsgroups: microsoft.public.dotnet.framework.aspnet
| >> | NNTP-Posting-Host: 216.57.203.121
| >> | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| >> | Xref: TK2MSFTNGXA02.phx.gbl
| >> microsoft.public.dotnet.framework.aspnet:362835
| >> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| >> |
| >> | I am using a TreeView to perform navigation and have a few nodes that
| >> need
| >> | to generate a popup menu. For this, I use the SelectedNodeChanged
event
| >> and
| >> | then add the relevant "window.open" script to the page using the
| >> | ClientScript.RegisterStartupScript method.
| >> |
| >> | This seems to work fine, but if the user clicks on the same node
twice,
| >> the
| >> | event doesn't fire a second time. I assume this is by design as the
| >> Node
| >> | Selection hasn't changed, but anyone know of a way to clear the
| >> selection
| >> | without clearing all of the nodes on the TreeView and repopulating
| >> them?
| >> |
| >> |
| >> | Thanks,
| >> |
| >> |
| >> | Andrew
| >> |
| >> |
| >> |
| >>
| >
| >
|
|
|
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top