Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Page.Controls.Add() + Response.Write()

Page.Controls.Add() + Response.Write()

Scheduled Pinned Locked Moved ASP.NET
questionhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NaNg15241
    wrote on last edited by
    #1

    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.

    G 1 Reply Last reply
    0
    • N NaNg15241

      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.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      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; }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups