Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

Reference another file from code-behind page...?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bodyboarder20 - 09 Jun 2007 14:32 GMT
Hey,

I'm sure this is an easy question for most.

I would like to create a class with a bunch of "library" functions...
But I'm not sure how I would configure it so that I can call functions
from one "code" file from another "code behind" file....

Page1.aspx ---> Page1.aspx.cs ---> globallibrary.cs

Is this possible?

Thanks!
Juan T. Llibre - 09 Jun 2007 14:47 GMT
re:
!> I would like to create a class with a bunch of "library" functions...
!> But I'm not sure how I would configure it so that I can call functions
!> from one "code" file from another "code behind" file....

Place globallibrary.cs in the App_Code directory.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
> Hey,
>
[quoted text clipped - 9 lines]
>
> Thanks!
Bodyboarder20 - 09 Jun 2007 15:42 GMT
Do I need to put any spacial tags at the top of the page1.aspx.cs file
to point it to the globallibrary.cs file?
Bodyboarder20 - 09 Jun 2007 15:43 GMT
Oh, btw... this is .NET 1.1  ( I know, my work is nuts )

> !> from one "code" file from another "code behind" file....
>
[quoted text clipped - 19 lines]
>
> - Show quoted text -
Juan T. Llibre - 09 Jun 2007 16:02 GMT
For ASP.NET 1,1, compile the code from the command-line,
and import/reference the resulting assembly.

Open a command window and make sure the
1.1 .Net Framework directory is in your system path, by running

PATH= %PATH% & C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;

Substitute the correct drive letter if you're booting from a different drive.

Also, if you have a non-standard Windows install,
replace "windows" with your custom-named install directory.

To compile a single source code file, use :

csc /t:library /out:globallibrary.dll globallibrary.cs

To compile all .cs files in a directory to globallibrary.dll ,
use : csc /t:library /out:globallibrary.dll *.cs

If you need to reference a .Net Framework assembly or assemblies,
add them, separated by slashes :

csc /t:library /r:system.dll /r:system.data.dll /out:globallibrary.dll *.cs

Once you have compiled your assembly, place it in the /bin
directory of your application, and import your class Namespace in any aspx page:

<%@ Import Namespace="YourNameSpace" %>

If you're working with VS.NET, compile your assembly
as described and add a reference to it in your VS.NET project.

That will allow you to use Intellisense and get your
assembly's properties, methods, etc. when coding.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
Oh, btw... this is .NET 1.1  ( I know, my work is nuts )

> !> from one "code" file from another "code behind" file....
>
[quoted text clipped - 22 lines]
>
> - Show quoted text -
Bodyboarder20 - 09 Jun 2007 16:10 GMT
Perfect solution!!!

Thanks so much!!!!!!!
Juan T. Llibre - 09 Jun 2007 16:56 GMT
re:
!> Perfect solution!!!

Except that I fudged the path to the 1.1 Framework directory...

That should have been :

PATH= %PATH%;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322;

Sorry...

Other than that, everything stands...and you're quite welcome.

:-)

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================

> Perfect solution!!!

> Thanks so much!!!!!!!
Alexey Smirnov - 09 Jun 2007 14:48 GMT
> Hey,
>
[quoted text clipped - 9 lines]
>
> Thanks!

globallibrary_class_name.public_static_function_name();

public class globallibrary_class_name
{
public static string public_static_function_name()
{
return "hello";
}
}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.