So i have a form and one of the fields may include one item or may require more fields to be created immediately to accommodate the extra input. so something like below:
FieldName:—— +
The plus sign would be clicked to get another field:
FieldName:—— +
FieldName2:—— +
…. so on
Sorry for poor illustration. I am looking to do this in an asp.net page. any idea how? need ajax component?
Thanks,
EDIT:
Protected Sub Button1_Click( ByVal sender As Object , ByVal e As System.EventArgs) _
Handles Button1.Click
Dim t As TextBox
t = New TextBox
PlaceHolder1.Controls.Add(t)
End Sub
This code would add one textfield. But if I want to add more, i am unable to do so…
You could create a Placeholder control and onclick (postback) of the ‘+’ button add a new control (e.g. Textbox) to the
Controlscollection of the Placeholder.You would need to remember to re-add any controls to the placeholder upon subsequent postbacks (within the
OnInit()preferably). This is so that previously added controls and their values can be retained.