Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using this Javascript below to dynamically add controls to an asp.net web form, which is working perfectly well. I need to add onClick event to the Button to pull data from SQL server database to auto populate the textboxes. Can somebody help me or guide me how to do that.


Javascript code
--------------------
XML
<script type="text/javascript">
       function addRow(tableID)
       {
           var newRow = document.getElementById("empRec1").insertRow(0);

           var oCell = newRow.insertCell(0);
           oCell.innerHTML = "<input type='Button' name='t1' size='9' Value='Select Employee'>";
           oCell = newRow.insertCell(1);
           oCell.innerHTML = "<input type='text' name='t2' size='2'>";
           oCell = newRow.insertCell(1);
           oCell.innerHTML = "<input type='text' name='t2' size='2'>";
           oCell = newRow.insertCell(1);
           oCell.innerHTML = "<input type='text' name='t2' size='2'>";
           oCell = newRow.insertCell(1);
           oCell.innerHTML = "<input type='text' name='t2' size='2'>";

       }



   </script>
Posted
Comments
For that you need to add onClick event to the button and call one javaScript function on that.
Then you can do an Ajax request to the code behind and get the data from Database.

If you need this type of example, then I can provide you...

Thanks...
Member 1283347 25-Sep-12 10:06am    
Yes, can you please provide me an example. I will appreciate it very much
Arunprasath Natarajan 25-Sep-12 12:49pm    
Better you can use Ajax

1 solution

you can use raw ajax to achieve this..
check out this link for sample code..
Raw AJAX
[^]
 
Share this answer
 

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