473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Running same code on differint pages

On the load part of 6 differint aspx pages I wish to run the same
code. Instead of having the same code on 6 pages it would be kind of
nice to have it in one place and include/call it.

How should I do this?

Regards /Snedker
Jan 2 '07 #1
3 913
You can create a Function library. Check out this tutorial from
ASPNet101.com:
http://aspnet101.com/aspnet101/tutorials.aspx?id=43

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Morten Snedker" <fi**@alotofsites.comwrote in message
news:t8********************************@4ax.com...
On the load part of 6 differint aspx pages I wish to run the same
code. Instead of having the same code on 6 pages it would be kind of
nice to have it in one place and include/call it.

How should I do this?

Regards /Snedker

Jan 2 '07 #2
"Morten Snedker" <fi**@alotofsites.comwrote in message
news:t8********************************@4ax.com...
On the load part of 6 differint aspx pages I wish to run the same
code. Instead of having the same code on 6 pages it would be kind of
nice to have it in one place and include/call it.

How should I do this?
Create a separate class and put your code in it.
Jan 2 '07 #3
Compile an assembly from the command-line,
and reference the dll in any page you want to use it from.

See:
http://msdn.microsoft.com/library/de...ommandline.asp

In short:

You can compile the assemblies manually.

Open a command window ( cmd.exe ) and make sure that the .Net Framework
directory is in your path ( the .Net dir is where the vb and cs compilers are located ) ;
navigate to the directory where you have your .vb files, and run the compile command :

vbc /t:library /out:myFile.dll myFile.vb

myFile.dll will be created/compiled in the current directory.

Move the assembly to the /bin directory of your application and fire away.
If you want to have VS.NET use it, reference it in your project.

If you want to use C#, then the command line would be :

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

If you need to import .Net classes, include them in your command line:

vbc /t:library /r:system.dll /r:system.web.dll /out:common.dll common.vb
csc /t:library /r:system.data.dll /r:system.web.dll /out:common.dll common.cs

After you compile the assembly, call it in your .aspx pages with :

<%@ Import Namespace="YourClassName" %>

Now, you can reference your methods ( in the aspx page ) with :

YourClassName.YourMethod

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/
===================================
"Morten Snedker" <fi**@alotofsites.comwrote in message
news:t8********************************@4ax.com...
On the load part of 6 differint aspx pages I wish to run the same
code. Instead of having the same code on 6 pages it would be kind of
nice to have it in one place and include/call it.

How should I do this?

Regards /Snedker


Jan 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mee Yamo | last post by:
Fellas!! This is a very complicated one and it took me a few days to figure out exactly what's going on, but here's the final story: I have a production environment running on .NET with a SQL...
3
by: Sravani | last post by:
Hi, I am setting up a new server for an already running website. The problem is the person before me ran ASP scripts on .html extension pages (The old machine is a windows 2000 server with IIS...
4
by: Bill Thorne | last post by:
We have a COM object that has been wrappered for use in .NET and which can make calls which can take a while to execute. These are mainframe integration calls that might perform a lot of data...
16
by: TB | last post by:
Hi all: If you think that the following comments are absolute amateurish, then please bear with me, or simply skip this thread. A couple of months back I made the decision to initiate a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.