I am adding rows to a dynamically created table through javascript and I wanted to get its values on postback.
Here’s the table:
<table id="summ" width="350px" border="1" >
Javascript snippet to add rows:
$('#summ > tbody:last').append('<tr><td><input type="button" id="delete" value="Delete"></td><td>' + sup + '</td><td>' + qty + '</td><td><input type="text"></td></tr>');
How do I get the values of the cells appended to the table after a button is clicked? “summ” is not recognized because if I put runat=server on the table tag, the Javascript doesn’t work.
You may define AJAX (WebMethod) method in code behind (add reference of System.Web.Services) and use $.ajax or $.post to request it. Have a look at code-snippet I’ve posted for your reference.
Sample.aspx (Code inline)
If you want to use “runat” attribute then add an empty inside the and write ClientID attribute.
jQuery code
OR