QA


Q&A

Q1:

Is there any difference in the HTML markup sent to the browser for a Literal and Label Web control?

A1:

Recall from our discussions in this hour that when the ASP.NET engine executes an ASP.NET page, the Web controls are rendered into HTML markup. The precise HTML generated depends on the Web control's properties.

In this hour we discussed two different Web controls: the Literal Web control and the Label Web control. If you create an ASP.NET page with Literal and Label Web controls and set the Text property of both to This is a test, when you're visiting the ASP.NET web page through a browser, it may appear as if both Web controls produce the same HTML output. However, it is important to note that the Label Web control produces slightly different HTML markup than the Literal Web control.

In such a web page, the HTML markup produced by the Literal control is

This is a test 


Note that the HTML markup produced by a Literal control is precisely the value of its Text property.

The Label Web control, however, actually uses a <span> HTML tag to display its Text property. That is, the HTML markup generated by the Label Web control in this example is

<span>This is a test</span> 


The Label Web control wraps its Text property in a <span> HTML tag so that it can add formatting. For example, if the Label Web control's Font property's Bold subproperty is set to true, the following HTML markup is produced in an uplevel browser:

<span style="font-weight:bold;">This is a test</span> 


Q2:

The ASP.NET engine renders Web controls differently if the page is visited by a downlevel browser versus an uplevel browser, but how common are downlevel browsers?

A2:

Modern browsers, ones released in the past several years, are tagged as uplevel browsers by the ASP.NET engine. Downlevel browsers, on the other hand, encompass rather antiquated browsersversion 4 or earlier of Netscape and version 3 or earlier of Internet Explorer. As we saw in this hour, a Web control that appears correctly in an uplevel browser might not appear so in a downlevel browser. To ensure that your pages work well in both uplevel and downlevel browsers, you would need to test your pages in both classes of browsers.

Before you rush off and download Netscape 4, take a moment to consider whether your efforts are worth the reward. How many people are using these outdated browsers? Are there enough real-world users to justify spending additional time in perfecting your site's appearance for this minority?

Various sites online post browser usage. One such site is TheCounter.com, which has browser usage statistics available at http://www.thecounter.com/stats/. At the time of this writing (November 2005), TheCounter.com had counted more than 75 million web requests for the month, of which about 63,000 (or 0.08%) came from what would be dubbed a downlevel browser. Clearly, it's a tiny fraction of the total traffic. The vast bulk of requests came from Internet Explorer 5.0 and 6.0, FireFox, Safari, Netscape 7.0, and Opera.

Realistically, you probably don't need to concern yourself with the slightly downlevel browsers, unless your site is geared toward those who might be using antiquated computers, such as people in less technologically advanced countries.




Sams Teach Yourself ASP. NET 2.0 in 24 Hours, Complete Starter Kit
Sams Teach Yourself ASP.NET 2.0 in 24 Hours, Complete Starter Kit
ISBN: 0672327384
EAN: 2147483647
Year: 2004
Pages: 233

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