views:

2971

answers:

2
<a id="lblShowTimings"
     runat="server"
     title='<%# Eval("SHOW_Name") %>'
     onclick='PopulateTicketDiv(<%#Eval("SHOW_ID") %>)'>  <-- this is the problem
  %#Eval("SHOW_Time") %>
</a>

Can Eval be passed as an argument to a javascript function? If so whats the syntax?

+4  A: 

Yes. What you want to do is this, though:

onclick='<%# "PopulateTicketDiv(" +Eval("SHOW_ID") + " );" %>'

tvanfosson
A: 

Try

<script type="javascript">
     //Pollute the global namespace
     var ticketDivID = <%= SHOW_ID %>
</script>

<a id="lblShowTimings" runat="server" title='<%# Eval("SHOW_Name") %>' onclick='PopulateTicketDiv(ticketDivID)'> <%#Eval("SHOW_Time") %></a>

On a side note because you've got runat="server" you can set the onclick from the backend in OnRowDataBound if this is in a grid/repeater or on page_load if not.

Rob Stevenson-Leggett