0

私は自分のアプリケーションで Jquery を使用して複数の TextBoxes を追加しています。その後、コード ビハインド ファイルで Request.form[name] によって値にアクセスできます。これらのテキストボックスを繰り返し処理し、ユーザーが入力したテキストの値を読み取って、データベースに保存できるようにします。これらのテキストボックスの値をデータベースに保存する方法を教えてください。私はasp.net 2.0で作業しています

$(document).ready(function () {

  var counter = 2;

  $("#addButton").click(function () {

   if (counter > 10) {
     alert("Only 10 textboxes allow");
     return false;
   }

   var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + counter);


   newTextBoxDiv.html('<table><tr><td><input type="text" name="textbox' + counter +
                          '" id="textbox' + counter + '" value="" ></td><td><input type="text" name="textbox' + counter +
                          '" id="textbox' + counter + '" value="" ></td><td><input type="text" name="textbox' + counter +
                          '" id="textbox' + counter + '" value="" ></td></tr></table>');

   newTextBoxDiv.appendTo("#TextBoxesGroup");
   return false;


   counter++;
  });
 });
4

1 に答える 1

1
        foreach (string key in Request.Form.AllKeys) 
        {
            if (key.StartsWith("textbox")) 
            {
                string value = Request.Form[key];
                //Do some stuff...
            }
        }
于 2013-03-05T15:52:24.927 に答える