<script  runat="server">
Sub submit(sender As Object, e As EventArgs)
dim i,j
table1.BGColor="yellow"
table1.BorderColor="red"
for i=0 To table1.Rows.Count-1
   for j=0 To table1.Rows(i).Cells.Count-1
     table1.Rows(i).Cells(j).InnerHtml="Row " & i
   next
next
End Sub
</script>


<!DOCTYPE html>
<html>
<body>

<form runat="server">
<table id="table1" border="1" runat="server">
   <tr>
     <td>Cell 1</td>
     <td>Cell 2</td>
   </tr>
   <tr>
     <td>Cell 3</td>
     <td>Cell 4</td>
   </tr>
</table>
<br>
<input type="button" value="Change Contents" OnServerClick="submit" runat="server"/>
</form>

</body>
</html>