0

I have an ASP.NET form where I add content () dynamicly using Javascript/jQuery:

$('#dynamicarea').append($('<input id="dyn1" type="text" value="awesome!">'));

On postback I tried to receive the content the following way:

protected void save_OnClick(object sender, EventArgs e) {
  foreach (var key in Request.Form.AllKeys) {
    // do fancy stuff
  }
}

But Request.Form.AllKeys do not seem to have the dynamically added input fields.

What is needed to access these fields from codebehind?

Ole Albers
  • 8,715
  • 10
  • 73
  • 166

1 Answers1

1

Since you have not added the name attribute, the Request.Form.AllKeys will not contain the item.

Modify the script to include the name attribute as below.

$('#dynamicarea').append($('<input id="dyn1" name="dyn1" type="text" value="awesome!">'));
Sherin Mathew
  • 1,141
  • 13
  • 19