Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add "using" to ASPX or ASCX file

Tags:

c#

.net

asp.net

Just out of curiosity...
Is there a way to add "using" to an ASPX/ASCX file?
eg. something like

<% using umbraco.NodeFactory; %>

So you can do

<%= Node.GetCurrent().Name %>

instead of

<%= umbraco.NodeFactory.Node.GetCurrent().Name %>
like image 329
Aximili Avatar asked Mar 06 '12 00:03

Aximili


1 Answers

You are looking for the @Import directive.

At the top of the control or page (can be mixed and matched with other directives):

<%@ Import Namespace="MyNamespace" %>

Or (different placing of the @ character):

<% @Import Namespace="MyNamespace" %>
like image 94
Tim M. Avatar answered Sep 22 '22 10:09

Tim M.