How to add control to the page programatically in page load?
问题 I am trying to add controls to the page from the code behind in the page load stage like this: foreach (FileInfo fi in dirInfo.GetFiles()) { HyperLink hl = new HyperLink(); hl.ID = "Hyperlink" + i++; hl.Text = fi.Name; hl.NavigateUrl = "../downloading.aspx?file=" + fi.Name + "&user=" + userIdpar; Page.Controls.Add(hl); Page.Controls.Add(new LiteralControl("<br/>")); } The error which I am getting is on Page.Controls.Add(hl) and here is the explanation: The control collection cannot be