Persisting imageUrl/cssClass through PostBack

4 posts, 0 answers
  1. Paweł Aszklar
    Paweł Aszklar avatar
    5 posts
    Member since:
    Jul 2009

    Posted 07 Sep 2009 Link to this post


    I have a bit of javascript to populate my RadListBox from WebService when the page is displayed for the first time. Based on some properties in the returned data I want to add imageUrl and/or cssClass to the RadListBoxItems i create. This is what I've come up with:


    <telerik:RadListBox ID="_rlbBrokers" runat="server" Skin="Default" PersistClientChanges="true"  
            SelectionMode="Multiple" height="200" /> 


    refreshBrokers: function() {  
            var me = this;  
            var brokersList = me.get_brokersList();  
            Ewita.WebServices.WarehousesService.GetBrokerItems(this._get_includedBrokerTypes(), this._get_includedWarehouseTypes(), this._permission, this._selectionMode, function(result) {  
                var brokersList = me.get_brokersList();  
                var items = brokersList.get_items();  
                var selected = false;  
                for (var i = 0; i < result.length; ++i) {  
                    var broker = result[i];  
                    var brokerItem = new Telerik.Web.UI.RadListBoxItem();  
                    if (broker.IsSelected) {  
                        selected = true;  
                    var li = brokerItem.get_element();  
                    if (!broker.IsUserPermitted && !broker.IsActive) {  
                        Sys.UI.DomElement.addCssClass(li, "inactive_not_permitted");  
                    else if (!broker.IsActive) {  
                        Sys.UI.DomElement.addCssClass(li, "inactive");  
                    else if (!broker.IsUserPermitted) {  
                        Sys.UI.DomElement.addCssClass(li, "not_permitted");  
                if (selected) {  

    It all works perfect until I click a button which causes a postback. I've set PersistClientChanges to true and items, and items selection is preserved, but any css class and image url set in javascript disappears.

    Is there a way to get around this problem?

    I'm using Telerik Controls for ASP.NET AJAX v.2009.2.906.20 (tested also on v.2009.02.826.35), Opera 10.0 browser, .NET Framework 3.5 and Visual Studio 2008.

    Thanks in advance.


    Paweł Aszklar

  2. Genady Sergeev
    Genady Sergeev avatar
    1600 posts

    Posted 10 Sep 2009 Link to this post

    Hi Paweł Aszklar,

    This is bug in the RadListBox. We have already added it in our bug-tracking system, however its priority was not that high. This is the reason why it is not fixed yet. I have tried to find a workaround, however I did not manage to find an easy one.

    Since this looks like a critical problem we will do our best to get it fixed by the beginning of the next week. I will write a follow up as soon as the problem is fixed. You will be able to access the fixed version of the RadListBox using the latest internal build. More information on how to obtain the latest internal can be found here.

    Sincerely yours,
    Genady Sergeev
    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.
  3. JD
    JD avatar
    22 posts
    Member since:
    Jul 2013

    Posted 19 Sep 2013 Link to this post

    Is this issue fixed?  I'm having the same issue. After postback, the proper checkbox states are maintained, but all the items' images are set to "greenLogo.gif" - when the javascript only sets the (single) checked one to that image.  The list sits on an ajax panel.


    this._RadList.ClientIDMode = System.Web.UI.ClientIDMode.Static;
    this._RadList.ID = "_RadList1";
    this._RadList.Height = Unit.Pixel(200);
    this._RadList.Width = Unit.Pixel(800);
    this._RadList.AllowReorder = true;
    this._RadList.EmptyMessage = "Must choose at least one";
    this._RadList.CheckBoxes = true;
    this._RadList.SelectionMode = ListBoxSelectionMode.Single;
    this._RadList.OnClientItemChecking = "singleSelectionInRgLb";
    this._RadList.OnClientTransferred = "";
    this._RadList.PersistClientChanges = true;

    function singleSelectionInRgLb(sender, args)
       var item = args.get_item();
       var items = sender.get_items();
       var checked = item.get_checked();
       if (checked == false)
    function clearChecks(items)
      items.forEach(function (itm)
  4. Bozhidar
    Bozhidar avatar
    1183 posts

    Posted 24 Sep 2013 Link to this post

    Hi Justyn,

    The issue has been fixes. However, the PersistClientChanges property works only for the transfer, reorder and delete operations that are built in the ListBox. For any other custom changes you would have to manually call the trackChanges() and commitChanges() methods of the listbox.

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top