markzzz markzzz - 7 months ago 36
C# Question

How can I use the "using" directive in a .ascx?

I'm bored, on writing C# code on .ascx, to use this syntax :

foreach (OriginalPackage.MyPack in OriginalPackage.MyPacks) {

instead of

foreach (MyPack in MyPacks) {

writing the right
using OriginalPackage;

So, is there a way to use the
on the .ascx?


Use the @import directive instead:

<%@ Import namespace="OriginalPackage" %>

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.