Friday, 3 February 2012

Working with Directives | ASP.Net Tutorial | ASP.Net Tutorial PDF

   For the most part, ASP.NET pages resemble traditional HTML pages with a few additions. In essence, just using the .aspx extension for an HTML file will ensure that IIS passes the page to the .NET Framework for processing. However, before you can work with certain, more advanced features, you’ll need to know how to use directives.
    We talked a little about directives and what they can do earlier in this chapter. You learned that directives control how a page is created, how a page is cached, help with bug-fixing, and allow us to import advanced functionality for use within our code. Three of the most commonly used directives are:

Page
This directive defines page-specific attributes for the ASP.NET page, such as the language used for server-side code. We’ve already seen this directive in use.

Import
The Importdirective makes functionality that’s been defined elsewhere available in a given page. The following example, for instance, imports functionality from the System.Web.Mail namespace, which you could use to send email from a page. Namespaces are simply .NET’s way of keeping all its functionality neatly organized.
<%@ Import Namespace="System.Web.Mail" %>
You’ll become very familiar with this directive as you work through this book.

Register
This directive allows you to register a user control for use on your page. We’ll cover Register in detail in next Topic but the directive looks something like this:
<%@ Register TagPrefix="uc" TagName="footer" Src="footer.ascx" %>