Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
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
--------------------
<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 24-Sep-12 16:46pm
Comments
Tadit Dash at 24-Sep-12 23:16pm
   
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 at 25-Sep-12 10:06am
   
Yes, can you please provide me an example. I will appreciate it very much
Arunprasath Natarajan at 25-Sep-12 12:49pm
   
Better you can use Ajax

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 410
1 Abhinav S 260
2 Nirav Prabtani 252
3 Andreas Gieriet 155
4 Dave Kreskowiak 155
0 OriginalGriff 7,545
1 Sergey Alexandrovich Kryukov 6,757
2 Maciej Los 3,909
3 Peter Leow 3,693
4 CHill60 2,712


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100