I am currently working on an asp.net web application where I have implemented a repeater that calls a registered user control. Within this user control, there is a button that is supposed to trigger a Javascript function to make an Ajax call for server-side actions. However, the button does not seem to be calling the Javascript method and upon inspecting the source code, I noticed that the Javascript function is being repeated for every item in the repeater. How can I prevent this repetition, especially since I need to access server items within the function? Additionally, why is the function not being called as expected?
Thank you!
sercontrol.ascx
<div id="divBtnEvent" runat="server">
<input type="button" id="btnAddEvent" class="ok-green" onclick="saveEvent();" />
</div>
<script type="text/javascript">
function saveEvent()
{
var eventText = document.getElementById('<%=txtEventDescription.ClientID%>').value;
// make ajax call
}