PanelBar Web Part Javascript Issues

2 posts, 0 answers
  1. Mike
    Mike avatar
    2 posts
    Member since:
    May 2009

    Posted 26 Jan 2010 Link to this post


    I've created a SharePoint web part for WSS 3.0 that displays a panel bar similar to one i created in an aspx page.  The problem I'm having is that after I've registered a client script block, the script I was using previously to capture what panel was selected, and then close all the others no longer works.  Previously I had the script triggered using OnClientItemClicked on the client side in the aspx page.  Since web parts are only server side, I've added an attribute to the RadPanelbar of onclick to trigger the script below.  Does anyone know why the script below doesn't work?
        function onclick(sender, args) {  
            var selectedtext = args.get_item().get_text();  
            var panelBar = $find("<%= RadPanelBar1.ClientID %>");  
            //close all other panels when item is clicked  
            var panelItem = panelBar.findItemByText("panel1");  
            panelItem = panelBar.findItemByText("panel2");  
            panelItem = panelBar.findItemByText("panel3");  
            panelItem = panelBar.findItemByText("panel4");  
            panelItem = panelBar.findItemByText(selectedtext);  
  2. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 28 Jan 2010 Link to this post

    Hello Mike,

    I already replied to your ticket:

    I look through your code and noticed that you are doing this:

    RadPanelBar1.Attributes.Add("onclick", String.Format("javascript: getControls('"+controlID+"')"));

    which is not the proper way to subscribe to the item click of a panelbar item. You need to use the
    OnClientItemClicked property.

    You can try this code:

    RadPanelBar1.OnClientItemClicked = "(function(sender, e){ getControls('" + controlID + "'); })";

    Is that what you need?

    Kind regards,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top