473,320 Members | 1,976 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,320 software developers and data experts.

Share VB code across multiple pages?

I am using ASP.NET 1.1.

In my web application, multiple pages will be using the same functions.
I am wondering if I can just pick out the shared code and save it in a
separate file and then imports it in my webpages.

Say if I save my VB functions in a file called mySharedCode.vb which
has for example a Sub called "ConvertTextBoxData", how do I call this
Sub in my page called page1.aspx?

Thanks a lot!

Nov 20 '05 #1
6 1609
re:
how do I call this Sub in my page called page1.aspx?
You don't.

What you do is compile "SharedCode.vb" to an assembly,
place the assembly in the /bin directory, and import your class's
namespace into any aspx page you want to use it in.

vbc /t:library /out:..\bin\SharedCode.dll SharedCode.vb /r:system.dll

If you need to add more .net classes, add them like this:
/r:system.dll /r:system.data.dll /r:system.xml.dll

Then, import your namespace into your aspx page :

<%@ Import Namespace="SharedCode" %>

This assumes that your class's namespace is named SharedCode.
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
<an***********@yahoo.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...I am using ASP.NET 1.1.

In my web application, multiple pages will be using the same functions.
I am wondering if I can just pick out the shared code and save it in a
separate file and then imports it in my webpages.

Say if I save my VB functions in a file called mySharedCode.vb which
has for example a Sub called "ConvertTextBoxData", how do I call this
Sub in my page called page1.aspx?

Thanks a lot!

Nov 20 '05 #2
OK. thanks. But it's like pain in the butt for me to compile my VB
code. When I tried doing that before, the system keeps saying that
this library is missing, that dll file is not found.

Nov 20 '05 #3
You have to know which assemblies you need to call.

Just add any required .net assemblies:

vbc /t:library /out:..\bin\SharedCode.dll SharedCode.vb /r:system.dll /r:system.data.dll

etc.

If it's a pain in the butt, you're doing it the wrong way... ;-)
It's quite easy, actually.

Use the class browser to find out what's where.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
<an***********@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
OK. thanks. But it's like pain in the butt for me to compile my VB
code. When I tried doing that before, the system keeps saying that
this library is missing, that dll file is not found.

Nov 20 '05 #4
Juan can VS.NET do this for you?
Patrick

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ed**************@TK2MSFTNGP11.phx.gbl...
You have to know which assemblies you need to call.

Just add any required .net assemblies:

vbc /t:library /out:..\bin\SharedCode.dll SharedCode.vb /r:system.dll /r:system.data.dll
etc.

If it's a pain in the butt, you're doing it the wrong way... ;-)
It's quite easy, actually.

Use the class browser to find out what's where.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
<an***********@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
OK. thanks. But it's like pain in the butt for me to compile my VB
code. When I tried doing that before, the system keeps saying that
this library is missing, that dll file is not found.


Nov 20 '05 #5
No.

VS.NET 2005 has a feature which could be useful,
which is placing class files in the App_Code directory.

They get compiled automatically, and can be referenced
in aspx pages, but that's not quite the same.

The ability to compile assemblies from the command-line is
one of the most powerful features the .Net Framework offers.

It makes the job of creating classes, and referencing them in aspx pages, a snap.

After they're compiled, adding a reference to them in VS.NET
lets you access all the classes, methods and properties with full intellisense.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Patrick.O.Ige" <pa********@optusnet.com.au> wrote in message
news:OM**************@TK2MSFTNGP10.phx.gbl...
Juan can VS.NET do this for you?
Patrick "Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ed**************@TK2MSFTNGP11.phx.gbl...
You have to know which assemblies you need to call.

Just add any required .net assemblies:

vbc /t:library /out:..\bin\SharedCode.dll SharedCode.vb /r:system.dll

/r:system.data.dll

etc.

If it's a pain in the butt, you're doing it the wrong way... ;-)
It's quite easy, actually.

Use the class browser to find out what's where.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
<an***********@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
> OK. thanks. But it's like pain in the butt for me to compile my VB
> code. When I tried doing that before, the system keeps saying that
> this library is missing, that dll file is not found.



Nov 20 '05 #6
Thx Juan
Awesome Juan.
Good Good.
Reading through some books for ASPNET 2.0 for now.
But will get my hands on it soon
Patrick
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:O5**************@tk2msftngp13.phx.gbl...
No.

VS.NET 2005 has a feature which could be useful,
which is placing class files in the App_Code directory.

They get compiled automatically, and can be referenced
in aspx pages, but that's not quite the same.

The ability to compile assemblies from the command-line is
one of the most powerful features the .Net Framework offers.

It makes the job of creating classes, and referencing them in aspx pages, a snap.
After they're compiled, adding a reference to them in VS.NET
lets you access all the classes, methods and properties with full intellisense.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Patrick.O.Ige" <pa********@optusnet.com.au> wrote in message
news:OM**************@TK2MSFTNGP10.phx.gbl...
Juan can VS.NET do this for you?
Patrick

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ed**************@TK2MSFTNGP11.phx.gbl...
You have to know which assemblies you need to call.

Just add any required .net assemblies:

vbc /t:library /out:..\bin\SharedCode.dll SharedCode.vb /r:system.dll

/r:system.data.dll

etc.

If it's a pain in the butt, you're doing it the wrong way... ;-)
It's quite easy, actually.

Use the class browser to find out what's where.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
<an***********@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
> OK. thanks. But it's like pain in the butt for me to compile my VB
> code. When I tried doing that before, the system keeps saying that
> this library is missing, that dll file is not found.



Nov 20 '05 #7

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

Similar topics

2
by: TaeHo Yoo | last post by:
Hi all, I have a solution which contains multiple projects. Those multiple projects should share the same session. For example, users login, create the session for users then these session...
3
by: Jon Paugh | last post by:
Hi, If I have several aspx pages that I want to share across multiple web applications, how would I organize them? Basically, a subset of the pages on a given site will be on several sites....
1
by: Jheitmuller | last post by:
Hi, What is the best way to share a C# web form across web application? I'm new to ASP.NET. I've read though the docs and I must be missing something. I do not see and appropriate library...
5
by: Raed Sawalha | last post by:
We have a web application with at least 570 Pages and 10's of user controls ....all under project name LinkDevProject ...recently we start separating the project into multiple projects ....the...
14
by: antonyliu2002 | last post by:
I am new to .NET framework. A bunch of web pages of mine need the same function. Right now, I put the Subs in each individual page. I think there must be a way to save my Subs in a separate...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
15
by: Neo | last post by:
Hello All, I found that ASP.net website only accepts code withing site directory. This creates big hurdle in shairng code. How to share code between two websites, like the way share between two...
4
by: Mike | last post by:
Class A public objX I want to create 2 or more instances of Class A and have the same value for objX in all instances. Instance1 of Class A Instance2 of Class A Instance3 of Class A
9
by: moondaddy | last post by:
I'm using asp.net 2.0 and c# and would like to share some user control between several websites. these websites are on the same server and have a physical location right next to each other like...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.