RadControls version
|
RadControls for ASP.NET AJAX |
.NET version |
2.x and 3.x |
Visual Studio version |
2005/2008 |
programming language |
JavaScript |
browser support |
all browsers supported by RadControls
|
GET REFERENCE TO AN ELEMENT INSIDE THE ITEM TEMPLATE
In some scenarios we need to get a reference to an item that is inside the Rotator's item template. For example we will get a reference to two types of objects - an HTML Image and an asp:Image control.
First we need to get a reference to the wrapper element. This element is used in the code in order to build the IDs of the controls that we want to refer to. The
RadRotator's
ItemTemplate is an ITemplate and the elements inside are renamed. For example if we have an asp:Image with ID="Image1" inside the template of a
RadRotator with ID="RadRotator1", the ID of the image in the first item becomes
RadRotator1_i0_AspImage1.
Getting the wrapper element :
Let us have the following setup, for example:
We implement two functions that can be used to find a specific item inside the ItemTemplate
- Get a reference to an HTML element that is inside the ItemTemplate
- Get a reference to an Asp control that is inside the ItemTemplate :
Note that in case you need to find an AJAX enabled control you need to use the
$find() function instead of the
$get() one.
Then we could use these functions inside the
OnClientItemClicked handler (for example) of the
RadRotator control and get references to the elements that are inside the currently clicked rotator's item :