findcontrol behaviour

T

tarscher

Hi all,

When a user clicks a button controls are generated
protected void keywordsDropDownList_SelectedIndexChanged(object
sender, EventArgs e)
{
int numberOfTextBoxes =
Convert.ToInt16(keywordsDropDownList.Text);
TextBox myTextBox;

for (int i = 0; i < numberOfTextBoxes; i++)
{
myTextBox = new TextBox();
myTextBox.ID = "parameterTextBox" + Convert.ToString(i);
myTextBox.Columns = 5;
buttonPlaceHolder.Controls.Add(myTextBox);
}
addKeywordButton.Visible = true;
MultiView1.SetActiveView(KeywordView);

TextBox myTB;
myTB =
(TextBox)buttonPlaceHolder.FindControl("parameterTextBox1");
}

The FindControl finds the parameterTextBox1 and copies it to myTB
correctly.

When a user now clicks a button after he clicked the previous one I do:
protected void addKeywordButton_Click(object sender, EventArgs e)
{
TextBox myTB;
myTB =
(TextBox)buttonPlaceHolder.FindControl("parameterTextBox1");
}

Here FindControl can't find the control and myTB is null.

I really can't find the problem so any help is greatly appreciated.

best regards
Stijn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top