![]() |
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! |
Re: Share VB code across multiple pages?
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/ ====================================== <antonyliu2002@yahoo.com> wrote in message news:1132340955.886441.7430@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! > |
Re: Share VB code across multiple pages?
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. |
Re: Share VB code across multiple pages?
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/ ====================================== <antonyliu2002@yahoo.com> wrote in message news:1132342569.480765.39120@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. |
Re: Share VB code across multiple pages?
Juan can VS.NET do this for you?
Patrick "Juan T. Llibre" <nomailreplies@nowhere.com> wrote in message news:edXEeqH7FHA.3984@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/ > ====================================== > <antonyliu2002@yahoo.com> wrote in message > news:1132342569.480765.39120@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. > > |
Re: Share VB code across multiple pages?
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" <patrickige@optusnet.com.au> wrote in message news:OMHPRAJ7FHA.4084@TK2MSFTNGP10.phx.gbl... > Juan can VS.NET do this for you? > Patrick > "Juan T. Llibre" <nomailreplies@nowhere.com> wrote in message > news:edXEeqH7FHA.3984@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/ >> ====================================== >> <antonyliu2002@yahoo.com> wrote in message >> news:1132342569.480765.39120@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. >> >> > > |
Re: Share VB code across multiple pages?
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" <nomailreplies@nowhere.com> wrote in message news:O5otugJ7FHA.1000@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" <patrickige@optusnet.com.au> wrote in message > news:OMHPRAJ7FHA.4084@TK2MSFTNGP10.phx.gbl... > > Juan can VS.NET do this for you? > > Patrick > > > "Juan T. Llibre" <nomailreplies@nowhere.com> wrote in message > > news:edXEeqH7FHA.3984@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/ > >> ====================================== > >> <antonyliu2002@yahoo.com> wrote in message > >> news:1132342569.480765.39120@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. > >> > >> > > > > > > |
| All times are GMT. The time now is 11:58 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.