c# - Handling button clicks in dynamically generated table -
<%foreach (var indication in model.findall(m => m.model != null && m.model.trx != null).orderby(m => m.model.trx.primarysponsor.company)) { %> <tr> <td><%= indication.displayuser %></td> <td><%= indication.activeindicationusers[0].fullname %></td> <td><%= string.isnullorempty(indication.model.trx.primarysponsor.company) ? "not yet saved" : indication.model.trx.primarysponsor.company %></td> <td><%= indication.timeopened.tostring(chatham.web.data.constants.format.datetimesecondsformatstring) %></td> <td><%= indication.model.trx.productcollection[0].producttypefriendlyname %></td> <td><%= (!indication.model.trx.id.hasvalue) ? "not yet saved" : indication.model.trx.id.value.tostring() %></td> <td><input type="button" value="open" name="<%= (!indication.model.trx.id.hasvalue) ? "not yet saved" : indication.model.trx.id.value.tostring() %>" /></td> </tr> <%} %> so above table, can see, dynamically generated. how handle button click? want pass name attribute of button whatever method handles button click.
thanks!
you can use live function of jquery.
try this:
$(function(){ $("td input[type=button][value=open]").live("click", function(e){ var btn = $(this); alert(btn.attr("name")); }); })
Comments
Post a Comment