<%@ Register TagPrefix="ec" Namespace="ASPNETExpert.WebControls" Assembly="ASPNETExpert.WebControls" %>
<%@ Register TagPrefix="ecd" Namespace="ASPNETExpert.WebControls.DemoControls" Assembly="ASPNETExpert.WebControls.DemoControls" %>
<%@ Control Language="c#" AutoEventWireup="True" Codebehind="ContextMenu.ascx.cs" Inherits="ASPNETExpert.WebControls.Demo.Tree.Advanced.ContextMenu" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<script language="javascript">
function OnRemoveHandler(menuItem, contextParam, treeNode) {
if(treeNode) {
if(menuItem.Value == 'Remove')
return confirm('The node ' + treeNode.Text + ' will be removed. Are you sure?');
if(menuItem.Value == 'RemoveChildren')
return confirm('All children of the node ' + treeNode.Text + ' will be removed. Are you sure?');
}
else
alert('No node!');
return true;
}
function MenuItemClicked(menuItem, contextParam, treeNode) {
if(!treeNode)
return;
if(menuItem.Value == 'RemoveOnClient') {
var parentNode = treeNode.GetParentNode();
treeNode.Remove();
parentNode.Update();
}
}
</script>
<table cellpadding="0" cellspacing="0" border="0" xmlns:ec="urn:http://aspnetexpert.com/ExpertControls.xsd">
<tr>
<td valign=top>
<ec:ExpertTree id="ContextMenuTree" runat="server" Skin="Classic" ContextMenuID="BuildTreeContextMenu" SelectOnClick="false" ExpandOnClick="true" CollapseOnClick="true">
<TreeLook Base="Classic" Width="250px" ShowLines="True" />
<Nodes>
<ec:TreeNode Text="Root 0" />
</Nodes>
</ec:ExpertTree>
<br>
<ec:ExpertTree id="ContextMenuTree2" runat="server" Skin="Classic" ContextMenuID="BuildTreeContextMenu" SelectOnClick="false" ExpandOnClick="true" CollapseOnClick="true">
<TreeLook Base="Classic" Width="250px" ShowLines="True" />
<Nodes>
<ec:TreeNode Text="Root 0" />
</Nodes>
</ec:ExpertTree>
</td>
<td valign=top width="100%" style="PADDING-LEFT:10px">
<ecd:DescriptionView runat="server" ID="Descriptionview1">
<ecd:Description id="Description1" runat="server">
Rigth-click on a node to pop up the context menu. </ecd:Description>
<ecd:Description id="Description2" runat="server">
Use power and flexibility of <b>ExpertContextMenu</b> control to implement
a context menu for any of the <b>ExpertTree</b> nodes.
</ecd:Description>
<ecd:Description id="Description3" runat="server">
Design and tune context menu(s) with <b>ExpertContextMenu</b> control and link it
to all tree nodes or any of the nodes by specifying <b>ContextMenuID</b> property for the
tree or for an individual node.
</ecd:Description>
<ecd:Description id="Description4" runat="server">
Raise PostBack when clicking a menu item by setting <b>PostBackOnClick</b> property for
a menu and process <b>ContextMenuItemSelected</b> tree's event at the server side.
</ecd:Description>
<ecd:Description id="Description5" runat="server">
Process menu's events at the client side using client-side API.
</ecd:Description>
</ecd:DescriptionView>
</td>
</tr>
</table>
<div xmlns:ec="urn:http://aspnetexpert.com/ExpertControls.xsd">
<ec:ExpertContextMenu id="BuildTreeContextMenu" runat="server" Skin="DarkBlue" EnableViewState="false" PostBackOnClick="true">
<OnClientBefore PostBackHandler="OnRemoveHandler" />
<OnClientAfter ItemClickHandler="MenuItemClicked" />
<TopGroup>
<Look Orientation="Vertical" Expand-Effect="GlideTopLeftToBottomRight" Expand-Duration="300" Collapse-Effect="GlideBottomRightToTopLeft" Collapse-Duration="300" />
<Items>
<ec:MenuItem Value="NewSibling" Text="New Sibling" />
<ec:MenuItem Value="NewChild" Text="New Child" />
<ec:MenuItem Value="Remove" Text="Remove" />
<ec:MenuItem Value="RemoveOnClient" Text="Remove on client side" PostBackOnClick="False" />
</Items>
</TopGroup>
</ec:ExpertContextMenu>
<ec:ExpertContextMenu id="BuildTreeExtContextMenu" runat="server" Skin="DarkBlue" EnableViewState="false" PostBackOnClick="true">
<OnClientBefore PostBackHandler="OnRemoveHandler" />
<OnClientAfter ItemClickHandler="MenuItemClicked" />
<TopGroup>
<Look Orientation="Vertical" Expand-Effect="GlideTopLeftToBottomRight" Expand-Duration="300" Collapse-Effect="GlideBottomRightToTopLeft" Collapse-Duration="300" />
<Items>
<ec:MenuItem Value="NewSibling" Text="New Sibling" />
<ec:MenuItem Value="NewChild" Text="New Child" />
<ec:MenuItem Value="RemoveChildren" Text="Remove Children" />
<ec:MenuItem Value="Remove" Text="Remove" />
<ec:MenuItem Value="RemoveOnClient" Text="Remove on client side" PostBackOnClick="False" />
</Items>
</TopGroup >
</ec:ExpertContextMenu>
</div>
<ec:CodeViewTab id="CodeViewTab1" runat="server">
<ec:TabItem runat="server" Text="aspx" ID="Tabitem1">
<pre class="aspcode">
<ecd:SyntaxHighlight runat="server" ContentType="ASPX" OutputFile="Advanced/ContextMenu.ascx" ID="Syntaxhighlight1"/>
</pre>
</ec:TabItem>
<ec:TabItem runat="server" Text="C#" ID="Tabitem2">
<pre class="aspcode">
<ecd:SyntaxHighlight runat="server" ContentType="C#" OutputFile="Advanced/ContextMenu.ascx.cs" ID="Syntaxhighlight2"/>
</pre>
</ec:TabItem>
<ec:TabItem runat="server" Text="VB" ID="Tabitem3">
<pre class="aspcode">
<ecd:SyntaxHighlight runat="server" ContentType="VB" OutputFile="Advanced/ContextMenu_vb.ascx.vb" ID="Syntaxhighlight3"/>
</pre>
</ec:TabItem>
</ec:CodeViewTab>