Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
ASP.NET: Defining Imports
From Wiki
Summary: Defining Imports
If you want to access a certain object in a namespace, you need to provide the full path to it e.g.
- Dim dt as New System.Data.DataTable
However, by adding an imports statement to the top of your class:
- Imports System.Data
you can now just write:
- Dim dt as New DataTable
However, you need to do this in every page or class where you need to reference the object. You can extend this functionality by adding the imports statements to the web.config file and they will then be available in every page or class:
- <pages>
- <namespaces>
- <clear/>
- <add namespace="System"/>
- <add namespace="System.Collections"/>
- <add namespace="System.Collections.Specialized"/>
- <add namespace="System.Configuration"/>
- <add namespace="System.Text"/>
- <add namespace="System.Text.RegularExpressions"/>
- <add namespace="System.Web"/>
- <add namespace="System.Web.Caching"/>
- <add namespace="System.Web.SessionState"/>
- <add namespace="System.Web.Security"/>
- <add namespace="System.Web.Profile"/>
- <add namespace="System.Web.UI"/>
- <add namespace="System.Web.UI.WebControls"/>
- <add namespace="System.Web.UI.WebControls.WebParts"/>
- <add namespace="System.Web.UI.HtmlControls"/>
- </namespaces>
- </pages>



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.