Welcome Guest Search | Active Topics | Sign In | Register

TreeView with ContextMenu can not work normally. Options
Jack.Wu
Posted: Friday, June 4, 2010 6:03:54 AM
Rank: Advanced Member
Groups: Member

Joined: 5/22/2009
Posts: 33
Hello Sir,

I followed the sample fo TreeView with ContextMenu but it can not pupup any menu. Please help to solve the problem. Thank you.

The code I tested is:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TreeViewDemo.aspx.cs" Inherits="KosmasWebTest.Demos.TreeViewDemo" %>
<%@ Register Src="../Control/ItemTree.ascx" TagName="ItemTree" TagPrefix="uc1" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<!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 runat="server">
<title>Untitled Page</title>
</head>

<body>
<script type="text/javascript">

function ShowContextMenu(e, treeView, node)
{
//Get the context menu object
var menu = eo_GetObject("<%=Menu1.ClientID%>");

//Modify the context menu
menu.getTopGroup().getItemByIndex(0).setText("Open '" + node.getText() + "'");
menu.getTopGroup().getItemByIndex(1).setText("Delete '" + node.getText() + "'");

//Display the context menu. See documentation
//for the Menu control for details about how
//to handle menu item click event
eo_ShowContextMenu(e, "<%=Menu1.ClientID%>");

//Returns true to indicate that we have
//displayed a context menu
return true;
}

</script>
<form id="form1" runat="server">
<div>
<eo:callbackpanel id="CallbackPanel1" runat="server" height="150px" width="200px">
<eo:TreeView ID="TreeView1" runat="server" AllowDragDrop="True" AllowDragReordering="True"
AllowEdit="True" ClientSideOnContextMenu="ShowContextMenu" ControlSkinID="None"
Height="250px" Width="200px">
<TopGroup Style-CssText="border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:black;cursor:hand;font-family:Tahoma;font-size:8pt;padding-bottom:2px;padding-left:2px;padding-right:2px;padding-top:2px;">
<Nodes>
<eo:TreeNode Text="Documents and Settings">
<SubGroup>
<Nodes>
<eo:TreeNode Text="Administrator">
</eo:TreeNode>
<eo:TreeNode Text="All Users">
</eo:TreeNode>
<eo:TreeNode Text="Default User">
</eo:TreeNode>
</Nodes>
</SubGroup>
</eo:TreeNode>
<eo:TreeNode Text="Program Files">
<SubGroup>
<Nodes>
<eo:TreeNode Text="Common Files">
</eo:TreeNode>
<eo:TreeNode Text="ComPlus Applications">
</eo:TreeNode>
<eo:TreeNode Text="Internet Explorer">
</eo:TreeNode>
<eo:TreeNode Text="MSDN">
</eo:TreeNode>
</Nodes>
</SubGroup>
</eo:TreeNode>
<eo:TreeNode Text="Windows">
<SubGroup>
<Nodes>
<eo:TreeNode Text="Fonts">
</eo:TreeNode>
<eo:TreeNode Text="Help">
</eo:TreeNode>
<eo:TreeNode Text="System32">
</eo:TreeNode>
</Nodes>
</SubGroup>
</eo:TreeNode>
</Nodes>
</TopGroup>
<LookNodes>
<eo:TreeNode CollapsedImageUrl="00030301" DisabledStyle-CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;color:Gray;padding-bottom:1px;padding-left:1px;padding-right:1px;padding-top:1px;"
ExpandedImageUrl="00030302" ImageUrl="00030301" ItemID="_Default" NormalStyle-CssText="PADDING-RIGHT: 1px; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; COLOR: black; BORDER-TOP-STYLE: none; PADDING-TOP: 1px; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: transparent; BORDER-BOTTOM-STYLE: none"
SelectedStyle-CssText="background-color:#316ac5;border-bottom-color:#999999;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#999999;border-left-style:solid;border-left-width:1px;border-right-color:#999999;border-right-style:solid;border-right-width:1px;border-top-color:#999999;border-top-style:solid;border-top-width:1px;color:White;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;">
</eo:TreeNode>
</LookNodes>
</eo:TreeView>
<eo:ContextMenu ID="Menu1" runat="server" ControlSkinID="None" Width="144px">
<TopGroup Style-CssText="cursor:hand;font-family:Verdana;font-size:11px;">
<Items>
<eo:MenuItem Text-Html="Open">
</eo:MenuItem>
<eo:MenuItem Text-Html="Delete">
</eo:MenuItem>
<eo:MenuItem IsSeparator="True">
</eo:MenuItem>
<eo:MenuItem Text-Html="Refresh">
</eo:MenuItem>
</Items>
</TopGroup>
<LookItems>
<eo:MenuItem IsSeparator="True" ItemID="_Separator" NormalStyle-CssText="background-color:#E0E0E0;height:1px;width:1px;">
</eo:MenuItem>
<eo:MenuItem HoverStyle-CssText="color:#F7B00A;padding-left:5px;padding-right:5px;"
ItemID="_Default" NormalStyle-CssText="padding-left:5px;padding-right:5px;">
<SubMenu CollapseEffect-Type="GlideTopToBottom" ExpandEffect-Type="GlideTopToBottom"
ItemSpacing="5" OffsetX="3" OffsetY="-4" ShadowDepth="0" Style-CssText="border-right: #e0e0e0 1px solid; padding-right: 3px; border-top: #e0e0e0 1px solid; padding-left: 3px; font-size: 12px; padding-bottom: 3px; border-left: #e0e0e0 1px solid; cursor: hand; color: #606060; padding-top: 3px; border-bottom: #e0e0e0 1px solid; font-family: arial; background-color: #f7f8f9">
</SubMenu>
</eo:MenuItem>
</LookItems>
</eo:ContextMenu>
</eo:callbackpanel>
</div>
</form>
</body>
</html>
eo_support
Posted: Friday, June 4, 2010 9:38:55 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,067
Hi,

Please place your script block inside your form element.

Thanks
Jack.Wu
Posted: Saturday, June 5, 2010 4:41:49 AM
Rank: Advanced Member
Groups: Member

Joined: 5/22/2009
Posts: 33
Hi Sir,

Thanks. It's ok.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.