Page.Controls.Add() + Response.Write()
-
Hello. I want to add a Control to my Page through the code-behind, and AFTER that, use the Response.Write cmd. eg.:
Page.Controls.Add(Page.LoadControl("Top.Ascx")); Response.Write("after");
Will this load the Control, and after the Control is loaded, it will write "after" or just the oposite? If it is oposite, how can I fix it? Thanks alot. NaNg. -
Hello. I want to add a Control to my Page through the code-behind, and AFTER that, use the Response.Write cmd. eg.:
Page.Controls.Add(Page.LoadControl("Top.Ascx")); Response.Write("after");
Will this load the Control, and after the Control is loaded, it will write "after" or just the oposite? If it is oposite, how can I fix it? Thanks alot. NaNg.It will first add the control to the control collection of the page object, then it will write the text to the output stream. As the controls of the page is rendered to the output stream after the Page_Load (and Page_PreRender), the text will end up before the entire page, even before the <htlm> tag. If you want to put text on the page, put it in a control, either one that you put on the page in advance, or one that you add to the page. A Literal control is suitable to put plain text on a page.
--- b { font-weight: normal; }