Click here to Skip to main content
15,850,545 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
function OnAddClick(){
str = "<tr id='" + ctrl + "'><td><input id='btn" + ctrl.toString() + "'" + " runat='server' value= '" + ctrl.toString() + "' type='button' onclick='GetId(this)'/></td>";
for (var i = 0; i < ctrlstr.length; i++) {
    str = str + "<td><asp:Label id='lbl" + document.getElementById(ctrlstr[i]).id + ctrl + "' runat='server' >" + document.getElementById(ctrlstr[i]).value + "</asp:Label></td>";
str = str + "</tr>";

function GetId(controlid) {
    var rowid =, 3);
    var table = $("#tblMain #" + rowid + "").find('Label')[0].id;

    for (var i = 0; i < ctrlstr.length; i++) {
        $("#" + document.getElementById(ctrlstr[i]).id + "").val($("#tblMain #" + rowid + "").find('Label')[i].innerHTML.toString());


In given code, I am adding one row to the table using OnAddClick() function.
OnAddClick() function add one new row to the table, which contains button also.
each time i am generating new button for a new row and adding it to the table. I have assigned a function name GetId() to that button.
On that button click, I am calling GetId() funtion by passing the Id of the button.
It works fine in IE9 but not in Chrome, Opera and Mozilla.
Please give me some suggestions regarding this.
bbirajdar 3-Dec-12 1:48am    
"It works fine in IE9 but not in Chrome, Opera and Mozilla." is not a proper technical description of the problem which can help us to identify the issue
gilvani 4-Dec-12 5:06am    
Hello you must pass the UniqueID in GetId () function, the ClientID does not work for the click event
Sudip Saha 5-Dec-12 3:25am    
Try it GetId(
VishwaKL 6-Dec-12 3:06am    
Check whether you blocked Java Script disabled ? in crome
Jameel VM 19-Dec-12 10:44am    
Please try jquery like this $(document).ready(function(){ $('button1').click(function(){

Your code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900