ContextMenu on Right-Click on a TreeNode in a TreeView

  •  07-13-2007, 1:47 PM

    ContextMenu on Right-Click on a TreeNode in a TreeView

    Hello,
     
    I am working on a TreeView Project using all the Microsoft Atlas Tools. I am now stuck on the final step that of getting a Right-Click ContextMenu on every TreeNode in the tree. I need to complete my project in a couple of days, hence it is a bit urgent
     
    Can you please help me this?
     
    Default.aspx:
     

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AJAXRajeev.Default" %>

    <%@ Register Assembly="AJAXRajeev" Namespace="VwdCms" TagPrefix="VwdCms1" %>

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head id="Head1" runat="server">

    <title>

    Sales Professional Desktop II

    </title>

     

    <script type="text/javascript">

    <!-- #include virtual="VwdCmsSplitterBar.js" -->

     

    function splitterOnResize(width)

    {

    if (typeof width == "string")

    {

    width = new Number(width.replace("px",""));

    }

    }

    </script>

    <script runat="server">

    void OnClick(Object sender, MenuEventArgs e)

    {

    e.Item.Selected = true;

    }

    </script>

    </head>

    <body>

    <form id="form1" method="post" runat="server">

    <div class="Default" style="float:left;">

    &nbsp;

    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true" AsyncPostBackTimeout="120">

    <Services>

    <asp:ServiceReference Path="WebService.asmx" />

    </Services>

    </asp:ScriptManager>

    <VwdCms1:SplitterBar ID="SplitterBar1" runat="server" LeftResizeTargets="tdTree1;divTree1" MinWidth="275"

    MaxWidth="800" BackgroundColor="lightsteelblue" BackgroundColorLimit="firebrick"

    BackgroundColorHilite="steelblue" BackgroundColorResizing="purple" SaveWidthToElement="txtWidth1"

    OnResize="splitterOnResize" style="background-image:url(vsplitter.gif);background-position:center center;background-repeat:no-repeat;"/>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="always" Visible="true">

    <ContentTemplate>

    <div style="margin:0px;padding:0px;width:800px;overflow:hidden;">

    <table border="0" cellpadding="0" cellspacing="0" style="width:800px;border:solid 1px #6699CC;">

    <tr style="width:auto;">

    <td id="tdTree1" style="width:560px;" align="left" valign="top">

    <div id="divTree1" style="width:100%;height:100%;overflow:auto;padding:0px;margin:0px;">

    <ajaxToolkit:TabContainer ID="tabs" runat="server" Width="" Height="1580px">

    <ajaxToolkit:TabPanel ID="tabHome" runat="server" HeaderText="Directory">

    <ContentTemplate>

    <asp:TreeView ID="TreeView1" runat="server" BackColor="Transparent" ExpandDepth="2"

    MaxDataBindDepth="2" SkipLinkText="skip nav" Target="~/Default.aspx" ToolTip="navigation"

    Font-Names="Verdana" Font-Size="Smaller" ForeColor="DarkKhaki"

    OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" ImageSet="Inbox"

    CollapseImageUrl="~/TreeLineImages/plus.gif" ExpandImageUrl="~/TreeLineImages/minus.gif"

    LineImagesFolder="~/TreeLineImages" NoExpandImageUrl="~/TreeLineImages/noexpand.gif" NodeWrap="True" BorderColor="Transparent" Width="405px">

    <ParentNodeStyle Font-Bold="False" ImageUrl="~/TreeLineImages/folder.gif"/>

    <HoverNodeStyle Font-Underline="True" />

    <SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px" ImageUrl="~/TreeLineImages/folder_open.gif" />

    <RootNodeStyle ImageUrl="~/TreeLineImages/folder.gif" />

    <LeafNodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" ImageUrl="~/TreeLineImages/folder_open.gif" />

    <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" ImageUrl="~/TreeLineImages/folder_open.gif" />

    </asp:TreeView>

    </ContentTemplate>

    </ajaxToolkit:TabPanel>

    <ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="Search">

    <ContentTemplate>

    <div>

    <ajaxToolkit:Accordion ID="Accordion1" runat="server" SelectedIndex="0" HeaderCssClass="accordionHeader" ContentCssClass="accordionContent" FadeTransitions="true" FramesPerSecond="40" TransitionDuration="250" AutoSize="None" Width="425px">

    <Panes>

    <ajaxToolkit:AccordionPane runat="server">

    <Header>

    <a href="" onclick="return false;">

    Section 1

    </a>

    </Header>

    <Content>

    The theme of the 2007 AllianceBernstein

    management conference in New York this

    January was "becoming the most admired

    investment firm in the industry."

    </Content>

    </ajaxToolkit:AccordionPane>

    <ajaxToolkit:AccordionPane runat="server">

    <Header>

    <a href="" onclick="return false;">

    Section 2

    </a>

    </Header>

    <Content>

    <asp:Menu ID="TreeViewMenu" runat="server" Orientation="Horizontal" onmenuitemclick="OnClick">

    <Items>

    <asp:MenuItem Text="Music">

    <asp:MenuItem Text="Classical" />

    </asp:MenuItem>

    <asp:MenuItem Text="Jazz" />

    <asp:MenuItem Text="Movies" Selectable="false">

    <asp:MenuItem Text="Action" />

    <asp:MenuItem Text="Drama" />

    <asp:MenuItem Text="Musical" />

    </asp:MenuItem>

    </Items>

    </asp:Menu>

    </Content>

    </ajaxToolkit:AccordionPane>

    </Panes>

    </ajaxToolkit:Accordion>

    </div>

    </ContentTemplate>

    </ajaxToolkit:TabPanel>

    </ajaxToolkit:TabContainer>

    </div>

    </td>

    <td id="td1" style="width:1000px;" align="left" valign="top">

    <asp:UpdatePanel ID="UpdatePanel2" runat="server" visible="true">

    <ContentTemplate>

    <ajaxToolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="TextBox1" WatermarkText="Click on the Node" />

    <asp:TextBox ID="TextBox1" runat="server" Width="382px" />

    </ContentTemplate>

    </asp:UpdatePanel>

    <asp:UpdateProgress ID="UpdateProgress2" AssociatedUpdatePanelID="UpdatePanel2" runat="server" Visible="true">

    <ProgressTemplate>

    External Documents

    </ProgressTemplate>

    </asp:UpdateProgress>

    &nbsp;&nbsp;&nbsp;

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"

    AllowPaging="True" BackColor="White" BorderColor="#999999" BorderStyle="None"

    BorderWidth="1px" CellPadding="3" Width="385px" GridLines="Vertical">

    <Columns>

    <asp:BoundField DataField= "Name" HeaderText="Child Nodes" />

    </Columns>

    <EmptyDataTemplate>

    <div style="text-align: center">

    No Data Available.

    </div>

    </EmptyDataTemplate>

    <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />

    <RowStyle BackColor="#EEEEEE" ForeColor="Black" />

    <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />

    <PagerStyle ForeColor="Black" HorizontalAlign="Center" BackColor="#999999" />

    <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />

    <AlternatingRowStyle BackColor="Gainsboro" />

    </asp:GridView>

    <asp:UpdatePanel ID="UpdatePanel3" runat="server" Visible="true">

    <ContentTemplate>

    &nbsp;

    </ContentTemplate>

    </asp:UpdatePanel>

    <asp:UpdateProgress ID="UpdateProgress3" runat="server" AssociatedUpdatePanelID="UpdatePanel3" Visible="true">

    <ProgressTemplate>

    External Documents

    </ProgressTemplate>

    </asp:UpdateProgress>

    </td>

    <td id="tdMid1" style="width:6px;" />

    <td id="tdEdit1" align="left" valign="top" style="" />

    </tr>

    </table>

    <span style="font-family:Verdana;font-size:10pt;" />

    </div>

    </ContentTemplate>

    </asp:UpdatePanel>

    <asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" runat="server" Visible="true">

    <ProgressTemplate>

    External Documents

    </ProgressTemplate>

    </asp:UpdateProgress>

    </div>

    <br />

     

    </form>

    </body>

    </html>
     
    Thanks in advance.
     
    Karamchand
View Complete Thread