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
90
WebExplorerBar get selected item text from OnItemClick event
posted

I am trying to get the text of the selected item when the user clicks on the item. I want to get this item text during a server-side ItemClick event. When I run my code the event triggers, but the ExplorerBarItemClickEventArgs e.Item is a null value and so is the WebExplorerBar1.SelectedItem.

 

Here is the code behind snippets:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // Group 1
            ExplorerBarGroup group = new ExplorerBarGroup();
            group.Text = "Folders";
            this.WebExplorerBar1.Groups.Add(group);


            ExplorerBarItem item = new ExplorerBarItem();
            item.Text = "Documents";
            group.Items.Add(item);

            item = new ExplorerBarItem();
            item.Text = "Samples";
            group.Items.Add(item);

            // Group 2
            group = new ExplorerBarGroup();
            group.Text = "Drives";
            this.WebExplorerBar1.Groups.Add(group);

            item = new ExplorerBarItem();
            item.Text = "C:";
            group.Items.Add(item);

            item = new ExplorerBarItem();
            item.Text = "D:";
            group.Items.Add(item);

            // Group 3
            group = new ExplorerBarGroup();
            group.Text = "Miscellaneous";
            this.WebExplorerBar1.Groups.Add(group);

            item = new ExplorerBarItem();
            item.Text = "Worksheet.xls";
            group.Items.Add(item);

            item = new ExplorerBarItem();
            item.Text = "Pic.png";
            group.Items.Add(item);

        }
        
    }

    protected void WebExplorerBar1_OnItemClick(object sender, ExplorerBarItemClickEventArgs e)
    {
        string temp1 = "";
        string temp2 = "";

        if (e.Item != null)
        {
            temp1 = e.Item.Value.ToString();
        }

        if (WebExplorerBar1.SelectedItem != null)
        {
            temp2 = WebExplorerBar1.SelectedItem.Value.ToString().Trim();
        }

    }

Here is the ASP code:

<%@ Page Language="C#" MasterPageFile="~/MasterPageSystem.master" AutoEventWireup="true"
    CodeFile="contentHome.aspx.cs" Inherits="contentHome" Title="Home Page"  %>

<%@ MasterType VirtualPath="~/MasterPageSystem.master" %>

<%@ Register assembly="Infragistics2.WebUI.UltraWebGrid.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.WebUI.UltraWebGrid" tagprefix="igtbl" %>
<%@ Register assembly="Infragistics2.Web.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.NavigationControls" tagprefix="ig" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentInfoPages" runat="Server">

<script type="text/javascript">
   
    function itemClick(sender, args) {
        var item = args.getExplorerBarItem();
        item.set_text(item.get_text() + " - Clicked");
    }

</script>

    <div style="margin: 20px 10px 20px 10px; text-align: center;">
        <div style="width: 99%;">
            <div style="float: left; background: #FFF000; width: 20%;">
               
                <ig:WebExplorerBar
                        ID="WebExplorerBar1"
                        runat="server"
                        AnimationDuration="200"
                        AnimationEquationType="Linear"
                        AutoPostBackFlags-ItemClick="On"
                        OnItemClick="webexbarFabSeries_OnItemClick"
                        EnableExpandButtons="true"
                        EnableSelection="true"
                        GroupExpandAction="ButtonClick"
                        GroupExpandBehavior="AllExpanded"
                        EnableViewState="true"
                        EnableAjaxViewState="true"
                        Width="99%"                    
                        StyleSetName="Office2007Black">

                    <AutoPostBackFlags ItemClick="On" ItemSelected="Off" />
                   
                </ig:WebExplorerBar>
            </div>
           
            <div style="float: right; background: #00FF00; width: 80%;">

                <div style="background: #FF0000; width: 99%;">
                </div>
                <div style="background: #00FFF0; width: 99%;">
                </div>

            </div>
           <div style="clear: both;">
            </div>
           
 
        </div>       
    </div>
</asp:Content>

 

 

Parents
No Data
Reply
  • 8160
    posted

    Hello workmama,

    e.Item.Text returns the selected Item text, but you should change: OnItemClick="webexbarFabSeries_OnItemClick" with OnItemClick="WebExplorerBar1_OnItemClick" because WebExplorerBar1_OnItemClick is not executed.

    Please let me know if this is working for you

     

     

Children