Click here to Skip to main content
12,761,018 members (30,864 online)
Rate this:
 
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 17:46pm
Comments
Tadit Dash 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 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

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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2017
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