Skip to content

Commit 54b31db

Browse files
authored
kb(rotator): add article get iframe inside item template
1 parent e6d02d0 commit 54b31db

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: Get reference to iframe inside ItemTemplate
3+
description: Get reference to iframe inside ItemTemplate. Check it now!
4+
type: how-to
5+
page_title: Get reference to iframe inside ItemTemplate
6+
slug: rotator-get-reference-to-iframe-inside-itemtemplate
7+
res_type: kb
8+
---
9+
10+
## Description
11+
12+
Sometimes, one might want to get a reference to an **iframe** element inside the ItemTemplate of the Rotator
13+
14+
## Solution
15+
16+
The easiest way to get the iframe element would be to attach a handler to the Rotator's [`ItemDataBound`]({%slug rotator/server-side-programming/events%}) server-side event and find the target iframe element in the current item:
17+
18+
````ASP.NET
19+
<telerik:RadRotator RenderMode="Lightweight" ID="RadRotator1" runat="server" OnItemDataBound="RadRotator1_ItemDataBound">
20+
<ItemTemplate>
21+
<iframe id="iframe1" runat="server">
22+
<asp:Image runat="server" ID="image1" />
23+
</iframe>
24+
</ItemTemplate>
25+
</telerik:RadRotator>
26+
````
27+
28+
````C#
29+
private void Page_Load(object sender, System.EventArgs e)
30+
{
31+
if (!IsPostBack)
32+
{
33+
RadRotator1.DataSource = GetRotatorDataSource();
34+
RadRotator1.DataBind();
35+
}
36+
}
37+
38+
private string[] GetRotatorDataSource()
39+
{
40+
string[] clients = { "ANATR", "ANTON", "BOTTM", "CACTU", "CENTC", "ERNSH", "LAUGB", "MAISD", "MEREP", "OCEAN" };
41+
return clients;
42+
}
43+
44+
protected void RadRotator1_ItemDataBound(object sender, RadRotatorEventArgs e)
45+
{
46+
HtmlIframe iframe = e.Item.Controls[1] as HtmlIframe; // Find the iframe server control
47+
}
48+
````
49+
50+
51+
52+

0 commit comments

Comments
 (0)