Base.Master
<asp:PlaceHolder ID="pnlDebug" Visible="true" runat="server"></asp:PlaceHolder>
Base.Master.cs
public void Debug(string Value = "") { pnlDebug.Controls.Add(new LiteralControl(string.Format("<div>{0}</div>", Value))); }
Test.aspx
<%@ MasterType VirtualPath="~/Base.master" %>
Test.aspx.cs
// debug if (Configuration.Debug) { Debug(string.Format("SessionID: {0}", Configuration.SessionID)); Debug(string.Format("Language: {0}", Configuration.Language)); }
The reason I like this approach is because it gives you the ability to avoid using Response.Write for debugging, which can mangle your layout while testing. It also allows you to build in optional debugging that you can turn on and off through the session and/or querystring (for example) to make debugging easier for applications where step-through debugging is not an option.
0 comments: