table id="TABLE1" borderColor="#95d5ff" width="800" border="1">
<script language="javascript">
function add(){
var tr;
tr=TABLE1.insertRow();tr.insertCell().innerHTML='<input name="text4" type="text" size="10"></input>';
tr.insertCell().innerHTML='<input name="text5" type="text" size="10"></input>';
tr.insertCell().innerHTML='<input name="text6" type="text" size="10"></input>';
//TABLE1.insertRow().insertCell().innerHTML = '<td width="200"bgcolor="#95d5ff"="#95d5ff"><div align="center">办公室</span></div>';
}
<button id="BUTTON1" onclick="add()" type="button" runat="server">add</button>
这段代码实现了动态加行,可是我要把加入的新行的文本框中的内容取出来插入数据库中,请问如何实现,如何从后台.net的.cs文件中读取javascript中的变量值?

解决方案 »

  1.   

    cs
       [AjaxPro.AjaxMenth()]  //好像是记不清楚了
      public void AddDB(string str)
     {
       //添加到数据库的代码......
      }  html
     
    <script language=javascript>
       function button_onclick()
      {
        var str=input.value;
        App.WebForm1.AddDB(str,AddDB_CallBack);
      }
       
       function AddDB_CallBack(str,response)
       {
          if(response.error==null)
            {
              alert("添加成功!");
              return;
            }
            else
            {
              alert(response.value);
              return;
             }
          }  
    </script>
      <input type="text" id="input">
      <input type="button" id="button1" onclick="button_onclick();">
    刚学的献丑了