Re: How to share VB code across multiple pages?



Hi, Juan,

Yes, I am using ASP.NET 1.1. I tried compiling MyClass.vb using
vbc.exe, but got an error message as follows:

"The application has failed to start because MSVCR71.dll was not
found.Reinstalling this application may fix this problem"

But MSVCR71.dll is actually right there under the folder
Windows\Microsoft.NET\Framework\v1.1.4322. How to fix this please?

By the way, how to get ASP.NET 2.0? Is it freely upgradable?


Juan T. Llibre wrote:
> If you're using ASP.NET 2.0, place MyClass.vb
> in the App_Code folder. You'll be able to access it there.
>
> If you're using ASP.NET 1.1, you should command-line compile
> MyClass.vb to MyClass.dll and place it in the /bin drectory.
>
> You, then, can import the namespace in your aspx file with :
> <%@ Import Namespace="YourNameSpaceName" %>
> and instantiate your classes from any aspx page.
>
>
>
> 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/
> ======================================
> <antonyliu2002@xxxxxxxxx> wrote in message
> news:1127931941.719998.234850@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > Hi, Thx.
> >
> > After I got your reply, then I created a file called "MyClass.vb" in
> > the same folder of the webpages.
> >
> > MyClass.vb has a Class like this:
> >
> > Public Class MyClass
> > Public Sub MySub()
> > Do Something
> > End Sub
> > End Class
> >
> > I called the MySub like this in my webpage:
> >
> > Call MyClass.MySub()
> >
> > This is the compile error:
> >
> > BC30456: 'MySub' is not a member of 'ASP.Page1_aspx'.
> >
> > Apparently I did not do it in the right way. I think I am doing it
> > like Java. I was a Java programmer.
> >
> > Shouldn't I tell Page1.aspx where to find that function?
> >
> > darrel wrote:
> >> > 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 file and then
> >> > have each web page link to it. Could you guys please let me know how
> >> > to do this? Thanks a lot!
> >>
> >> There are a variety of ways. One way is to just make a new class file (a .vb
> >> or .cs file) and then reference the function that way.
> >>
> >> I typically make a new class file called sharedFunctions and then put
> >> specific functions within it. I can then reference them from any file in the
> >> project: sharedFunctions.myFunction()
> >>
> >> -Darrel
> >

.



Relevant Pages

  • Re: Return to form if query unmatched
    ... following error message upon opening the form: ... Set Myrst = .OpenRecordset ... These reference can add from Code Windows> Tools Menu> Reference ... Check Marks to following and compile it. ...
    (microsoft.public.access.queries)
  • Re: [SLE] Please! I could use some help!
    ... I don't know what SuSE distribution you are running -- I came in late on ... "NULL" error message ... to ensure he was getting a working installation. ... and do some simple compile development exercises until you gain the ...
    (SuSE)
  • Re: Error exiting database
    ... without error if you choose 'Compile ' form the Debug ... > The Load Event looks like this but I don't understand why it would fire ... >> The error message, though, indicates that the problem is in the Load ... >> GlobalSign digital certificate is a forgery and should be deleted without ...
    (microsoft.public.access.formscoding)
  • Re: using #ifndef
    ... > gone to the newsgroup as well. ... that was ERT's fault for sending his response both by ... but nothing that anyone else could actually compile. ... cut-and-paste the actual error message. ...
    (comp.lang.c)
  • Re: Make Exe problem
    ... When compiling an ActiveX component with binary compatibility set to the ... LINK fatal error LNK1104 cannot open file. ... Set binary compatibility to the copied file, and compile ... If you click "Yes," the following error message appears: ...
    (microsoft.public.vb.bugs)