@Import Syntax and Importing Namespaces in global.asax file

D

D. Shane Fowlkes

Tw part question:
1 - Is it <% @Import Namespace..... or <%@ Import Namespace... ? I'm seeing
it both ways in a book (but I think one is a typo. My pages don't seem to
care which it is. Or do they?....see below

2 - I'm trying to import the namespaces of System.Data and
System.Data.SQLClient in the global.asax file so I don't have to do this on
each page using SQL Server commands and data. But it doesn't seem to work.
I read you can do this. What's the trick if it's possible to do this? My
@Imports are above my <script> tag in the asax file like so:

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>


<script language="vb" runat="server">
Sub Session_OnStart
....etc

Thanks guys!
 
T

Tu-Thach

inline
-----Original Message-----
Tw part question:
1 - Is it <% @Import Namespace..... or <%@ Import Namespace... ? I'm seeing
it both ways in a book (but I think one is a typo. My pages don't seem to
care which it is. Or do they?....see below

I don't think it matters.
2 - I'm trying to import the namespaces of System.Data and
System.Data.SQLClient in the global.asax file so I don't have to do this on
each page using SQL Server commands and data. But it doesn't seem to work.
I read you can do this. What's the trick if it's possible to do this? My
@Imports are above my <script> tag in the asax file like so:

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>


<script language="vb" runat="server">
Sub Session_OnStart
....etc

You have to import it into each individual page.

Tu-Thach
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top