RadPanelBar

3 posts, 0 answers
  1. Mateusz
    Mateusz avatar
    14 posts
    Member since:
    Aug 2012

    Posted 06 Mar 2013 Link to this post

    I want to use the middle mouse button to open choosen link in new tab. The middle button works but it opens current loaded url. Not the one that is clicked by the mouse middle button.
    I tried to debug it but when i press the middle button it does not fire the OnItemClicked event.
    How can i fix that?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Mar 2013 Link to this post

    Hello Mateusz,

    If you are setting the NavigateUrl property of the item, then both usual click as well as middle button click does not fire server side onitemclick event.

    Instead you can use the OnClientItemClicked client side event and force a PostBack to invoke the server-side onitemclick event. Please have a look at the following code I tried.

    ASPX:
    <telerik:RadPanelBar ID="RadPanelBar" runat="server" OnClientItemClicked="OnClientItemClicked"
        OnItemClick="RadPanelBar_ItemClick">
        <Items>
            <telerik:RadPanelItem runat="server" Text="Item1">
                <Items>
                    <telerik:RadPanelItem runat="server" Text="Item11" NavigateUrl="http://www.yoururl1.com">
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem runat="server" Text="Item12" NavigateUrl="http://www.yoururl2.com">
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem runat="server" Text="Item13">
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem runat="server" Text="Item14">
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelItem>
        </Items>
    </telerik:RadPanelBar>

    JavaScript:
    <script type="text/javascript">
        function OnClientItemClicked(sender, args) {
            var handler = $telerik.$('span.rpOut');
            if (handler) {
                __doPostBack();
            }
        }
    </script>

    C#:
    protected void RadPanelBar_ItemClick(object sender, Telerik.Web.UI.RadPanelBarEventArgs e)
    {
        //business logic goes here.
    }

    Thanks,
    Princy.
  3. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Mar 2013 Link to this post

    Hello Mateusz,

    If you are setting the NavigateUrl property of the RadPanelBar item, then the server-side OnItemClick event wont be fired on usual single click as well as middle button click on the item.

    Instead you can attach the OnClientItemClicked event of the RadPanelBar to force a PostBack of the page to invoke the server-side OnItemClick event. Please have a look into the following code I tried at my end.

    ASPX:
    <telerik:RadPanelBar ID="RadPanelBar" runat="server" OnClientItemClicked="OnClientItemClicked"
        OnItemClick="RadPanelBar_ItemClick">

    Javascript:
    <script type="text/javascript">
        function OnClientItemClicked(sender, args) {
            var handler = $telerik.$('span.rpOut');
            if (handler) {
                __doPostBack();
            }
        }
    </script>

    Thanks,
    Princy.
Back to Top