Modify style in Server Side Event

2 posts, 1 answers
  1. Artur
    Artur avatar
    2 posts
    Member since:
    Dec 2015

    Posted 06 Apr Link to this post

    Hi!

    I wanted to modify style of RadCombo on server side, something like this:

    01.protected void SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    02.    {
    03.        var radCombo = sender as RadComboBox;
    04.        var parent = radCombo.Parent;
    05. 
    06.       // cuted...
    07. 
    08.        int constLeft = 130;
    09.        int avgTokenWidth = 73;
    10.        int computed = constLeft + (avgTokenWidth * autocomplete.Entries.Count);
    11.        radCombo.Style["Left"] = computed.ToString() + " px ! important";
    12.    }

     

    But it doesn't do anything. How to push these change to the client?

     

  2. Answer
    Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 11 Apr Link to this post

    Hello Artur,

    Generally, you can achieve this requirement using the client-side equivalent:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/combobox/client-side-programming/events/onclientselectedindexchanged

    As for the server-side approach, you will need to use the correct CSS approach depending on your requirements:
    protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        RadComboBox combo = sender as RadComboBox;
        combo.Style["margin-left"] = "100px";
    }

    Regards,
    Eyup
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top