Click here to Skip to main content
15,887,975 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Guys

In My content includes textbox, ddl, reqfield and...

how can i access all items in repeater with JavaScript

thanks everyone

What I have tried:

ASP.NET
<asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
           <script type="text/javascript">
                 function MyFunc() { 
                     $('#box_<%#Eval("ID")%>').slideToggle("500");
                     var ReqFieldValidator = document.getElementById("<%=ReqFieldValidator.ClientID%>");
                     ReqFieldValidator.enabled = false;
                 } 
           </script>

        <asp:CheckBox ID="MyCheckBox_chk" onclick="MyFunc()" runat="server" />

        <div id='box_<%#Eval("ID")%>'>
              <asp:RequiredFieldValidator ID="ReqFieldValidator" runat="server">       </asp:RequiredFieldValidator>
             // Div Content
        </div> 

   </ItemTemplate>
</asp:Repeater>
Posted
Comments
Bryian Tan 5-Mar-18 2:19am    
have you try passing the id into MyFunc? Something like MyFunc('<%#Eval("ID")%>')
Member 10871138 5-Mar-18 3:36am    
I tried
but not working

<asp:CheckBox ID="MyCheckBox" onclick='MyFunc(<%#Eval("ID")%>)' runat="server" />

div
id="<%#Eval("ReminderID")%>"
/div



MyFunc(id)
{
$(id).slideToggle("500");
}
A_Griffin 5-Mar-18 3:52am    
Why are you putting a JS function inside a repeater item? It will get repeated in each row, and you'll end up with the same function defined multiple times on your page.... place your function outside of the repeater and pass the CientIDs to it
Member 10871138 5-Mar-18 4:46am    
you are right
i changed code
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900