Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
UltraWebMenu problem
posted

Hi all I am not able to fire event for Ultrawebmenu. I am using master page for my application. I am using Visual Studio 2008 and Infragistics version 8.2.20082.1000.

Below is my code

Region.aspx

<%@ Page Language="C#" MasterPageFile="~/MasterPages/Details.master" AutoEventWireup="true"

Inherits="Pages_Region_Region" meta:resourcekey="PageResource1" CodeBehind="Region.aspx.cs" %>

<%@ Register Assembly="Infragistics35.WebUI.UltraWebNavigator.v8.2, Version=8.2.20082.1000, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"

Namespace="Infragistics.WebUI.UltraWebNavigator" TagPrefix="ignav" %>

<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="Server">

<script type="text/javascript" id="igClientScript">

 

//document.oncontextmenu=new Function("return false");// right click disable

 

function UltraWebTree1_NodeClick(treeId, nodeId, button){

//Add code to handle your event here.

var node = igtree_getNodeById(nodeId);

if(node == null)

return;

 

//force this node to be selected so actions in the popup are based on this node

node.setSelected(true);

 

//this textbox is for debugging to make sure we get the proper tag value

var txt = document.getElementById("Text1");

var tag=node.getTag();

 

var arr = tag.split("|");

var nodeType=arr[0];

txt.value=nodeType;

//Determine if the node clicked allows the popup menu option this information is stored in the Tag property

if(button == 2){

if(nodeType=='region')

{

var tree = igtree_getTreeById(treeId);

 

igmenu_showMenu('ctl00ContentUltraWebMenuRegion', tree.event);

return true;

}

if(nodeType=='subregion')

{

var tree = igtree_getTreeById(treeId);

igmenu_showMenu('ctl00ContentUltraWebMenuSubregion', tree.event);

return true;

}

}

}

// -->

function GetNodeType(tag)

{

var arr = tag.split("|");

return arr[0];

}

function UltraWebTree1_DragStart(oTree, oNode, oDataTransfer, oEvent)

{

if(GetNodeType(oNode.getTag())!='country' && GetNodeType(oNode.getTag())!='subregion')

{

alert("You can only move countries and regions");

}

else

{

oDataTransfer.dataTransfer.setData("Text", oNode.getText());

oDataTransfer.dataTransfer.effectAllowed = "move";

}

}

function UltraWebTree1_Drop(oTree, oNode, oDataTransfer, oEvent){

var sourceNode = oDataTransfer.sourceObject;

if(!oNode.isChildOf(sourceNode))

{

var newNode=oNode.addChild(oDataTransfer.dataTransfer.getData("Text"));

newNode.setTag(sourceNode.getTag());

 

oNode.setExpanded(true);

 

CopyChildNodes(sourceNode,newNode);

 

if(sourceNode)

sourceNode.remove();

}

return false;

}

function CopyChildNodes(source,dest)

{

var nodes=source.getChildNodes();

if(nodes!="")

{

var i=0;

while (i < nodes.length)

{

var nodename=nodes[i].getText();

 

var newnode = dest.addChild(nodename);

i++;

 

}

}

}

// -->

 

// -->

function UltraWebTree1_AfterBeginNodeEdit(treeId, nodeId){

//Add code to handle your event here.

//Add code to handle your event here.

var node = igtree_getNodeById(nodeId);

if(node == null)

return;

 

if(GetNodeType(node.getTag())!='subregion')

{

//alert(node.getTag());

var tree;

tree = igtree_getTreeById(treeId);

tree.endEdit(false);

 

 

}

 

}

// -->

</script>

<table style="height: 100%; width: 100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td style="height: 2px; background-image: url(../../Images/MercerHR/dot.gif)" colspan="2">

</td>

</tr>

<tr>

<td style="width: 10px">

</td>

<td>

<asp:Label ID="ErrorLabel" runat="server" CssClass="ErrorTitle" meta:resourcekey="ErrorLabelResource1"></asp:Label>

<asp:ValidationSummary ID="ValidationSummary1" CssClass="ErrorTitle" HeaderText="Error information:"

DisplayMode="List" runat="server" meta:resourcekey="ValidationSummary1Resource1" />

<br />

</td>

<td style="width: 10px">

</td>

</tr>

<tr>

<td style="height: 10px">

</td>

</tr>

<tr>

<td style="width: 10px">

</td>

<td style="width: 100%" align="left" valign="top">

<table cellpadding="0" cellspacing="0" class="StepsTitleTable" width="100%">

<tr>

<td align="left">

<ignav:UltraWebTree ID="UltraWebTree1" runat="server" AllowDrag="True" AllowDrop="True"

BorderStyle="Solid" BorderWidth="1px" DefaultImage="ig_treeFolder.gif" DefaultSelectedImage="ig_treeFolderOpen.gif"

Editable="True" FileUrl="" Font-Names="Microsoft Sans Serif" Font-Size="9pt"

Height="297px" HoverClass="" Indentation="20" TargetFrame="" TargetUrl="" WebTreeTarget="ClassicTree"

Width="298px">

<NodeEditStyle Font-Names="Microsoft Sans Serif" Font-Size="9pt">

</NodeEditStyle>

<Images>

<DefaultImage Url="ig_treeFolder.gif" />

<SelectedImage Url="ig_treeFolderOpen.gif" />

<ExpandImage Url="ig_treePlus.gif" />

<CollapseImage Url="ig_treeMinus.gif" />

</Images>

<ClientSideEvents AfterBeginNodeEdit="UltraWebTree1_AfterBeginNodeEdit" BeforeBeginNodeEdit=""

DragStart="UltraWebTree1_DragStart" Drop="UltraWebTree1_Drop" NodeClick="UltraWebTree1_NodeClick" />

<Levels>

<ignav:Level Index="0" />

<ignav:Level Index="1" />

</Levels>

<Nodes>

<ignav:Node Expanded="True" TagString="root" Text="All Regions">

<Nodes>

<ignav:Node TagString="region" Text="Africa">

</ignav:Node>

<ignav:Node Expanded="True" TagString="region" Text="Americas">

</ignav:Node>

<ignav:Node Expanded="True" TagString="region" Text="Asia">

</ignav:Node>

<ignav:Node Expanded="True" TagString="region" Text="Europe">

</ignav:Node>

</Nodes>

</ignav:Node>

</Nodes>

<SelectedNodeStyle BackColor="Navy" BorderStyle="Solid" BorderWidth="1px" Cursor="Default"

ForeColor="White">

<Padding Bottom="1px" Left="2px" Right="2px" Top="1px" />

</SelectedNodeStyle>

</ignav:UltraWebTree>

<ignav:UltraWebMenu ID="UltraWebMenuRegion" runat="server" JavaScriptFilename=""

JavaScriptFileNameCommon="" LeafItemImageUrl="/ig_common/images/LeafImage.bmp"

OnMenuItemClicked="UltraWebMenuRegion_MenuItemClicked" ParentItemImageUrl="/ig_common/images/LeafImage.bmp"

StyleSetName="" WebMenuTarget="PopupMenu" BackColor="#F0F0F0" BorderColor="#F0F0F0"

BorderStyle="Outset" BorderWidth="2px" DisabledClass="" FileUrl="" Font-Names="Microsoft Sans Serif"

Font-Size="9pt" TargetFrame="" TargetUrl="" TopItemSpacing="Compact" TopSelectedClass="">

<Styles>

<ignav:Style BackColor="#303030" BorderStyle="Outset" BorderWidth="1px" CssClass="TopHover4"

Cursor="Default" ForeColor="White">

<Margin Bottom="0px" Left="0px" Right="0px" Top="0px" />

<BorderDetails ColorBottom="255, 128, 0" ColorLeft="255, 128, 0" ColorRight="255, 128, 0"

ColorTop="255, 128, 0" StyleBottom="Solid" StyleLeft="Solid" StyleRight="Solid"

StyleTop="Solid" WidthBottom="1px" WidthLeft="2px" WidthRight="1px" WidthTop="1px" />

</ignav:Style>

<ignav:Style BorderColor="#F0F0F0" BorderStyle="Solid" BorderWidth="1px" CssClass="TopClass4">

</ignav:Style>

</Styles>

<IslandStyle BackColor="#F0F0F0" BorderColor="Black" BorderStyle="Outset" BorderWidth="1px"

Cursor="Default" Font-Names="MS Sans Serif" Font-Size="8pt" ForeColor="Black">

</IslandStyle>

<HoverItemStyle BackColor="DarkBlue" BorderColor="Gray" BorderStyle="Solid" BorderWidth="1px"

Cursor="Default" ForeColor="White">

</HoverItemStyle>

<Images>

<ScrollTopDisabledImage Url="ig_menu_scrollup_disabled.gif" />

<ScrollBottomDisabledImage Url="ig_menu_scrolldown_disabled.gif" />

<LeafItemImage Url="/ig_common/images/LeafImage.bmp" />

<ParentItemImage Url="/ig_common/images/LeafImage.bmp" />

<SubMenuImage Url="ig_menutri.gif" />

<TopLevelItemImage Url="/ig_common/images/RootLeafImage.gif" />

<ScrollBottomImage Url="ig_menu_scrolldown.gif" />

<ScrollTopImage Url="ig_menu_scrollup.gif" />

</Images>

<ItemStyle BorderColor="#F0F0F0" BorderStyle="Solid" BorderWidth="1px" />

<Items>

<ignav:Item Text="New Subregion">

</ignav:Item>

</Items>

<DisabledStyle ForeColor="LightGray">

</DisabledStyle>

<Levels>

<ignav:Level Index="0" />

</Levels>

<SeparatorStyle BackgroundImage="ig_menuSep.gif" CustomRules="background-repeat:repeat-x; " />

<ExpandEffects ShadowColor="DarkGray" Delay="100" RemovalDelay="500" Type="Slide" />

<MenuClientSideEvents InitializeMenu="" ItemChecked="" ItemClick="" ItemHover=""

SubMenuDisplay="" />

</ignav:UltraWebMenu>

<ignav:UltraWebMenu ID="UltraWebMenuSubregion" runat="server" JavaScriptFilename=""

JavaScriptFileNameCommon="" LeafItemImageUrl="/ig_common/images/LeafImage.bmp"

OnMenuItemClicked="UltraWebMenuSubregion_MenuItemClicked" ParentItemImageUrl="/ig_common/images/LeafImage.bmp"

StyleSetName="" WebMenuTarget="PopupMenu" BackColor="#F0F0F0" BorderColor="#F0F0F0"

BorderStyle="Outset" BorderWidth="2px" DisabledClass="" FileUrl="" Font-Names="Microsoft Sans Serif"

Font-Size="9pt" TargetFrame="" TargetUrl="" TopItemSpacing="Compact" TopSelectedClass="">

<Styles>

<ignav:Style BackColor="#303030" BorderStyle="Outset" BorderWidth="1px" CssClass="TopHover4"

Cursor="Default" ForeColor="White">

<Margin Bottom="0px" Left="0px" Right="0px" Top="0px" />

<BorderDetails ColorBottom="255, 128, 0" ColorLeft="255, 128, 0" ColorRight="255, 128, 0"

ColorTop="255, 128, 0" StyleBottom="Solid" StyleLeft="Solid" StyleRight="Solid"

StyleTop="Solid" WidthBottom="1px" WidthLeft="2px" WidthRight="1px" WidthTop="1px" />

</ignav:Style>

<ignav:Style BorderColor="#F0F0F0" BorderStyle="Solid" BorderWidth="1px" CssClass="TopClass4">

</ignav:Style>

</Styles>

<IslandStyle BackColor="#F0F0F0" BorderColor="Black" BorderStyle="Outset" BorderWidth="1px"

Cursor="Default" Font-Names="MS Sans Serif" Font-Size="8pt" ForeColor="Black">

</IslandStyle>

<HoverItemStyle BackColor="DarkBlue" BorderColor="Gray" BorderStyle="Solid" BorderWidth="1px"

Cursor="Default" ForeColor="White">

</HoverItemStyle>

<Images>

<ScrollTopDisabledImage Url="ig_menu_scrollup_disabled.gif" />

<ScrollBottomDisabledImage Url="ig_menu_scrolldown_disabled.gif" />

<LeafItemImage Url="/ig_common/images/LeafImage.bmp" />

<ParentItemImage Url="/ig_common/images/LeafImage.bmp" />

<SubMenuImage Url="ig_menutri.gif" />

<TopLevelItemImage Url="/ig_common/images/RootLeafImage.gif" />

<ScrollBottomImage Url="ig_menu_scrolldown.gif" />

<ScrollTopImage Url="ig_menu_scrollup.gif" />

</Images>

<ItemStyle BorderColor="#F0F0F0" BorderStyle="Solid" BorderWidth="1px" />

<Items>

<ignav:Item Text="Delete Subregion">

</ignav:Item>

</Items>

<DisabledStyle ForeColor="LightGray">

</DisabledStyle>

<Levels>

<ignav:Level Index="0" />

</Levels>

<SeparatorStyle BackgroundImage="ig_menuSep.gif" CustomRules="background-repeat:repeat-x; " />

<ExpandEffects ShadowColor="DarkGray" Delay="100" RemovalDelay="500" Type="Slide" />

<MenuClientSideEvents InitializeMenu="" ItemChecked="" ItemClick="" ItemHover=""

SubMenuDisplay="" />

</ignav:UltraWebMenu>

</td>

</tr>

<tr>

<td align="left">

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Save" />

<br /><input id="Text1" type="text" />This text box show what type of node is being selected.

(root, region, subregion, country). This information is critical and used to determine

if popups need to show up and the content)

</td>

</tr>

<tr>

<td align="left">

&nbsp;

</td>

</tr>

<tr>

<td align="left">

&nbsp;

</td>

</tr>

<tr>

<td align="left">

&nbsp;

</td>

</tr>

</table>

<sidebarbuttonstyle width="100px" />

</td>

<td style="width: 10px">

</td>

</tr>

</table>

<div id="divResult" runat="server">

<br />

</div>

</asp:Content>

Region.aspx.cs

3 function related to onmenuitemclick

protected void UltraWebMenuRegion_MenuItemClicked(object sender,Infragistics.WebUI.UltraWebNavigator.
WebMenuItemEventArgs e)

{

if (e.Item.Text.ToLower() == "new subregion")

{

AddNodes(GetNextRegionName(), UltraWebTree1.SelectedNode.Text,
"subregion", UltraWebTree1);UltraWebTree1.SelectedNode.Expand(true);

}

}

//Get the next unique subregion name

private string GetNextRegionName()

{

string name = "New subregion";

int count = 1;while (UltraWebTree1.Find(name + count.ToString(), false) != null)

{

count++;

}

return name + count.ToString();

}

protected void UltraWebMenuSubregion_MenuItemClicked(object sender, WebMenuItemEventArgs e)

{

if (e.Item.Text.ToLower() == "delete subregion")

{

//moves the child nodes of the deleted subregion to the above region

Node oNode = UltraWebTree1.SelectedNode;Node parentNode = oNode.Parent;

parentNode.Nodes.AddRange(oNode.Nodes);

parentNode.Nodes.Remove(oNode);

}

}