@ Import
Explicitly imports a namespace into a page, making all classes and interfaces of the imported namespace available to the page. The imported namespace can be part of the .NET Framework class library or a user-defined namespace.
<%@ Import namespace="value" %>
Attributes
- namespace
The name of the namespace to import to the page. This can include any of the namespaces included in the .NET Framework or a custom namespace.
Remarks
The @ Import directive cannot have more than one namespace
attribute. To import multiple namespaces, use multiple @ Import directives.
The following namespaces are automatically imported into all pages:
- System
- System.Collections
- System.Collections.Specialized
- System.Configuration
- System.IO
- System.Text
- System.Text.RegularExpressions
- System.Web
- System.Web.Caching
- System.Web.Security
- System.Web.SessionState
- System.Web.UI
- System.Web.UI.HtmlControls
- System.Web.UI.WebControls
Example
The following code imports the .NET Framework base-class namespace System.Net and the user-defined namespace Grocery
:
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="Grocery" %>