Take the 2-minute tour ×

What I'm trying to achieve/plan, is whereby a page loads with a set of inputs, e.g. TextBox, Radio List etc. Taking TextBox as an example, there is a button for the user to "Add" another textbox to the page (in the same group), e.g. Member1, Member2, Member3 etc etc.

Two questions:

  1. I could add these with Javascript, however the resultant "save" on postback would not get these inputs? If so, how?

  2. The form needs to work without Javascript as well, so postback to dad another control is fine, however if I click the "add" button again, it will only ever add one control.

    protected void btnAdd_OnClick(object sender, EventArgs e) { holder.Controls.Add(new TextBox { ID = "txtControl1" }); }

share|improve this question
add comment

2 Answers

You can access the dynamic controls in the postback by name, using the following syntax "Page.Request.Form[""].ToString();". This uses the "name" attribute, not the "id" attribute.

share|improve this answer
add comment

I guess you can have one of these scenarios :
1- to save any new control ( textbox ) data in a session variable .. for example save name and value in which when any post back you can draw then again from this variable
2- If the only post back done from Add button you can do its function without doing post back as in this example http://msdn.microsoft.com/en-us/library/ms178210.aspx

share|improve this answer
add comment

Your Answer


