I have created several labels,textboxes, and buttons from an array. Now, I am not sure how to program those objects. For example, I want to program a button that will enable a text-box (from the array), capture variables, manipulate the variables, etc just like any other object that is in the form. Furthermore, I am working on ASP.net with C#.net back-end code. how do I double click on the object to generate the following block of code "private void btnDisplay_Click(object sender, EventArgs e)" and how do I make reference to a textbox as well to capture the input information?
The following code is within a button that is actually in the form and generates labels, textbox, and buttons.
Button [] buttons = new Button[2];
for (int i = 0; i < buttons.Length ; i++)
{
buttons[i] = new Button();
buttons[i].ID = "BTN0" + i;
if (i == 0)
{
buttons[i].Text = "Send Web API Request";
}
if (i == 1)
{
buttons[i].Text = "Manually Input Information";
}
}
for (int i = 0; i < buttons.Length ; i++)
{
pnlButton.Controls.Add(buttons[i]);
Literal lit = new Literal();
lit.Text = "</br></br>";
pnlButton.Controls.Add(lit);
}
TextBox[] textBoxes = new TextBox[n];
Label[] labels = new Label[n];
for (int i = 0; i < n; i++)
{
labels[i] = new Label();
labels[i].ID = "LBL0" + i;
labels[i].Text = lines3[i];
textBoxes[i] = new TextBox();
textBoxes[i].ID = "TXT0" + i;
}
for (int i = 0; i < n; i++)
{
pnlQuestionsLBLS.Controls.Add(labels[i]);
Literal lit = new Literal();
lit.Text = "</br></br>";
pnlQuestionsLBLS.Controls.Add(lit);
pnlQuestionsTXTS.Controls.Add(textBoxes[i]);
Literal lit2 = new Literal();
lit2.Text = "</br></br>";
pnlQuestionsTXTS.Controls.Add(lit2);
}
}