Response.Write output in code block is appearing outside html

前端 未结 1 958
旧巷少年郎
旧巷少年郎 2021-01-23 08:26

Putting aside any debate about whether you should even use Response.Write in the HTML portion of an .aspx, in a project I am working on variables from the code behind are being

相关标签:
1条回答
  • 2021-01-23 09:18

    Response.Write writes to the response stream. The reason that your data is added on the beginning of the response stream can only be that the event where your statements are triggered is before any of the Response.Write of ASP.NET start.

    You should typically override Render, RenderChildren or RenderControl to put your Response.Writes in, and make sure to call the proper parent methods, otherwise only your statements are visible. Alternatively, put your Response.Write inside server tags <% %> or use the suggestion of Naveed (which btw translates internally into a Response.Write anyway, but is much clearer and easier to write).

    EDIT summary of the extended chat below: the cause was found in the Telerik RadAjax.Net2 control. On removing that, the issue went away. Solved by Andreas himself.

    0 讨论(0)
提交回复
热议问题