TreeView SelectedNodeChanged Event

Discussion in 'ASP .Net' started by Andrew Robinson, Dec 5, 2005.

  1. 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
    Andrew Robinson, Dec 5, 2005
    #1
    1. Advertising

  2. 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" <>
    | 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#>
    | 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
    |
    |
    |
    Steven Cheng[MSFT], Dec 6, 2005
    #2
    1. Advertising

  3. 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

    "Steven Cheng[MSFT]" <> wrote in message
    news:5tBtIkk%...
    > 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" <>
    > | 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#>
    > | 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
    > |
    > |
    > |
    >
    Andrew Robinson, Dec 6, 2005
    #3
  4. Ok, I answered my own question:

    TreeView1.SelectedNode.Selected = false;

    This is what I was looking for.

    -Andrew

    "Andrew Robinson" <> wrote in message
    news:u5MmnJo%...
    > 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
    >
    > "Steven Cheng[MSFT]" <> wrote in message
    > news:5tBtIkk%...
    >> 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" <>
    >> | 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#>
    >> | 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
    >> |
    >> |
    >> |
    >>

    >
    >
    Andrew Robinson, Dec 6, 2005
    #4
  5. 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" <>
    | References: <ugjvv7c#>
    <5tBtIkk#>
    <u5MmnJo#>
    | 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#>
    | 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
    |
    | "Andrew Robinson" <> wrote in message
    | news:u5MmnJo%...
    | > 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
    | >
    | > "Steven Cheng[MSFT]" <> wrote in message
    | > news:5tBtIkk%...
    | >> 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" <>
    | >> | 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#>
    | >> | 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
    | >> |
    | >> |
    | >> |
    | >>
    | >
    | >
    |
    |
    |
    Steven Cheng[MSFT], Dec 7, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tanya foster
    Replies:
    1
    Views:
    3,576
    tanya foster
    Jun 5, 2006
  2. Replies:
    0
    Views:
    435
  3. Velislav

    TreeView SelectedNodeChanged event

    Velislav, Nov 24, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    672
    Velislav
    Nov 24, 2006
  4. Replies:
    1
    Views:
    706
  5. biker
    Replies:
    0
    Views:
    549
    biker
    Aug 3, 2006
Loading...

Share This Page