Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically add multiple controls II 1

Status
Not open for further replies.

Affleck

Technical User
Jun 19, 2001
26
GB
I have a linkButton that when clicked adds a control to a placeholder control collection.

When the user clicks the linkButton one HtmlInputFile control is added, but any subsequent clicks doesn't add any more controls to the placeholder!?

I have the following wired to the click event:

private void addFileUpload_Click(object sender, System.EventArgs e)
{
System.Web.UI.HtmlControls.HtmlInputFile addFile = new System.Web.UI.HtmlControls.HtmlInputFile();
addFile.Name = "addFile"+addFileCount;
addFile.ID = "addFile"+addFileCount;
plc_files.Controls.Add(addFile);
addFileCount++;
}

Any help appreciated.

TIA

Affleck



there are 10 types of people in this world those who understand binary, and those who don't.
 
I was expecting this to come up! [smile]

On your page load you don't create any of the the control. Therefore what happens is:

1) The page loads (no controls created)
2) The user clicks the "add control" button
3) The page loads (no controls created)
4) The control is added from the button click

What you need is some way of identifying which/how many controls have been loaded and make sure they are added from the page load event if it is a subsequent control.


----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
again, i feel foolish!! :)

Thanks, I'll add the controls to the view state!

there are 10 types of people in this world those who understand binary, and those who don't.
 
Don't feel foolish - sometimes these things just need a second pair of eyes - I know I've been in that situation myself.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top