Get ID of sender

2 posts, 0 answers
  1. Mike
    Mike avatar
    6 posts
    Member since:
    Nov 2006

    Posted 13 Dec 2007 Link to this post

    I've got a project where I will have 10 or more color pickers on a single page.  Each color picker will change different but similar elements on the page.

    I'd like to be able to write a single javascript function that handles all the element changes, but I cannot figure out how to determine which color picker has called the function.  I really need to get the sender's ID so I can determine which elements to change.

    An example of what I'm trying to do with a function that is hard coded to a set of elements for a single color picker.  If I get the ID color picker, I can adjust the correct elements.

    <script type="text/javascript">
    function changeBoxColor(sender, eventArgs)
    {
    var box = document.getElementById('<%=  divSearch.clientID %>');
    var header = document.getElementById('<%=  divSearchH.clientID %>');
    box.style.borderColor = sender.get_selectedColor();
    header.style.backgroundColor = sender.get_selectedColor();
    }
    </script>


    <div id="divSearch" runat="server" class="section" >
    <div id="divSearchH" runat="server" class="header">
    Search Box
    </div>
    <div class="inner">
    <table class="inputMin">
    <tr>
    <th>
    Outline Color
    </th>
    <td>
    <telerik:RadColorPicker
    ID="clrSearch"
    runat="server"
    Preset="Standard"
    ShowEmptyColor="False"
    ShowIcon="True"
    OnClientColorChange="changeBoxColor">
    </telerik:RadColorPicker>
    </td>
    </tr>
    <tr>
    <th>
    Text Color
    </th>
    </tr>
    </table>
    </div>
    </div>
  2. Petio Petkov
    Admin
    Petio Petkov avatar
    825 posts

    Posted 17 Dec 2007 Link to this post

    Hi Scott Neu,

    You can get the ID with sender.get_id() method in the handler. Take a look at the following example where this method is used:
    http://www.telerik.com/DEMOS/ASPNET/Prometheus/ColorPicker/Examples/ClientSideEvents/DefaultCS.aspx



    Best wishes,
    Petio Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top