How to Call a Javascript Function on DataBound RadPanel Bar

2 posts, 0 answers
  1. Prava kafle
    Prava kafle avatar
    217 posts
    Member since:
    Apr 2010

    Posted 06 Aug 2010 Link to this post

    I have a databound RadPanelBar  and I want call a javascript function  on clicking one of the RadItem.  I used "OnClientItemClicked" but it did not help. Any Idea why it is not working and how to fix it?

               RadPanelBar1.DataSource = dt;
                RadPanelBar1.DataFieldID = "ID";
                RadPanelBar1.DataFieldParentID = "ParentID";
                RadPanelBar1.DataTextField = "Label";
                RadPanelBar1.DataValueField = "KeyInCommand";

    protected void RadPanelBar1_ItemDataBound1(object sender, RadPanelBarEventArgs e)
            RadPanelItemCollection radItems = RadPanelBar1.Items;

     private void AttachClientEventtoRadItems(RadPanelItemCollection radItems)
            foreach (RadPanelItem radItem in radItems)
                string itemValue = radItem.Value;
                if (radItem.Controls.Count == 1)

    private void AttachOnClickEvent(RadPanelItem radItem)
            string itemValue = radItem.Value;
            if (string.Equals(itemValue, "ZOOM_PREVIOUS", StringComparison.CurrentCultureIgnoreCase))
                //String csname1 = "PopupScript";
                //String cstext1 = "<script type='text/javascript'>" + "function DoClick() { Map_Map1.ZoomToPrevousExtent(); alert('added'); return false; }</" + "script>";
                //NextGenProject.ParentPage.RegisterClientScriptBlock(csname1, cstext1);

                radItem.Attributes.Add("OnClientItemClicked", "OnClientItemClicked");

    JavascriptFunction :
    function OnClientItemClicked(sender, args) {
        alert("Button Is Clicked");

  2. Nikolay Tsenkov
    Nikolay Tsenkov avatar
    734 posts

    Posted 09 Aug 2010 Link to this post

    Hello Prava kafle,

    You can not attach an event handler specifically for an item. Instead, you can create a single event handler (handling the ClientItemClicked event of the RadPanelBar) and inside of it determine which element is currently clicked.

    Here is a nice little reference how to create the handler:

    Hope this is helpful for you!

    Nikolay Tsenkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top