This is a migrated thread and some comments may be shown as answers.

Get ID of sender

1 Answer 1241 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 13 Dec 2007, 09:50 PM
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>

1 Answer, 1 is accepted

Sort by
0
Petio Petkov
Telerik team
answered on 17 Dec 2007, 11:46 AM
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
Tags
ColorPicker
Asked by
Mike
Top achievements
Rank 1
Answers by
Petio Petkov
Telerik team
Share this question
or