Watermark in background for Debug build

  • Thread starter Thread starter David Slinn
  • Start date Start date
D

David Slinn

I was wondering what the best way to acheive the following would be:

What I would like is for the background of every page in my ASP.NET web
project to contain a soft red GIF containing the word "TEST" when the
version being viewed has been compiled using the DEBUG build. Once we build
a release version and place that into production, we obviously want that
"watermark" to disappear.

Now, I suppose I could create two cascading style sheets, one containing a
body - background entry for test, the other without it for production. Is
this the best method, or is there another way?

- Dave
 
If you haven't done so already, you could create a base class for the pages
in your project and in one of the page events (probably PreRender) you could
dynamically add a control using a directive

[C#]
#if DEBUG
Page.Controls.Add(new LiteralControl("<img src=\"test.gif\" />"));
#endif

[VB.NET]
#If DEBUG Then
Page.Controls.Add(new LiteralControl("<img src=""test.gif"" />"))
#End If

If there is a specific place you wish to place the image you could use the
AddAt method of the ControlCollection.

(I may be a little off on the syntax for VB.NET since I have only been using
C#)
 
Back
Top