I am facing a problem with access to HTML elements. On the server side those elements exists in itemTemplate of a repeater control.
simple code:
<asp:Repeater ID="rptList" runat="server" onitemcreated="rptList_ItemCreated">
<HeaderTemplate>
<div id="accordionGiftLelo">
</HeaderTemplate>
<ItemTemplate>
<div class="set">
<div class="title"><img src='<%# Eval("TitleImgUrl")%>' runat="server" width="198" height="29" /></div>
<div ID="RepeaterBG" class="content" style="background-color:<%# Eval("ContentBackground")%>">
<%--<a href='<%# Eval("ContentUrl")%>'><img src='<%# Eval("ContentImgUrl")%>' alt="Embroidered Devil Eyes" width="198" height="198" border="0" /></a>--%>
<div style="width:198"><asp:Literal ID="Literal1" runat="server" Text='<%# Eval("ContentImgUrl")%>'></asp:Literal></div>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
</asp:Repeater>
How can I access RepeaterBG div for example?
Here is an example on how to access controls server side and apply your data to them. Make sure to add the RunAt=”server” to the div tag.
add a reference for the ItemDataBound event
You will find that if you do this for ALL of your controls, instead of using “<%# Eval”, you’re code will be much easier to maintain.