Creating a Page That Counts Hits


The page we ll use for this example is very simple just some text and a single control. In a real application, a hit counter would probably be part of a page that contained other information. In this chapter, however, we ll concentrate on just creating a counter on a page, and you can adapt what you learn here to any page you like. So let s get started with our simple hit- counter page.

Lay out the hit-counter page

  1. In Web Matrix, create a page named  HitCounter.aspx.

  2. Add a Label control, and name it labelHitCounter. Clear its Text property.

  3. Optionally type in text to act as a heading and as a caption for the counter.

    You can use plain text to display the counter, as shown in Figure 8-2:

    click to expand
    Figure 8-2: Displaying the counter as plain text.

    You can also use fonts and colors to give the counter a distinctive look, as shown in Figure 8-3:

    click to expand
    Figure 8-3: Displaying the counter using a distinctive font and color.

For the example shown in Figure 8-3, I set the properties of the labelHitCounter label control as follows:

  • Font.Names=Verdana,Arial,Helvetica

  • Font.Size=Large

  • Font.Bold=True

  • ForeColor=Lime

  • BackColor=Black

  • BorderStyle=Ridge

  • BorderWidth=6px

  • BorderColor=#E0E0E0 (Type in this value if you want to get the same color I used.)

These settings will work with Microsoft Internet Explorer, but they might not work with every browser. For example, not all browsers allow you to put borders around text. Later in this chapter in the section named Creating Graphical Numbers, I ll show you a different way to format the counter by using a graphical display.




Microsoft ASP. NET Web Matrix Starter Kit
Microsoft ASP.NET Web Matrix Starter Kit (Bpg-Other)
ISBN: 0735618569
EAN: 2147483647
Year: 2003
Pages: 169
Authors: Mike Pope

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net