Freigeben über


@ Import

Explicitly imports a namespace into an ASP.NET application file (such as a Web page, a user control, a master page, or a Global.asax file), making all classes and interfaces of the imported namespace available to the file. The imported namespace can be part of the .NET Framework class library or a user-defined namespace.

<%@ Import namespace="value" %>

Attributes

  • namespace
    The fully qualified name of the namespace to import. 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.

A set of namespaces can be automatically imported into .aspx pages. The imported namespaces are defined in the machine-level Web.config file, within the <namespaces> section of the <pages> element. The following namespaces are automatically imported into all pages:

Example

The following code example imports the .NET Framework base-class namespace System.Net and the user-defined namespace Grocery.

<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="Grocery" %>

See Also

Reference

Directive Syntax

Concepts

ASP.NET Web Page Syntax Overview