Re: How to share VB code across multiple pages?
- From: antonyliu2002@xxxxxxxxx
- Date: 28 Sep 2005 11:25:41 -0700
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
.
- Follow-Ups:
- Re: How to share VB code across multiple pages?
- From: Juan T. Llibre
- Re: How to share VB code across multiple pages?
- Prev by Date: Re: ASP.net XML Encoding
- Next by Date: Re: Tracing simple question
- Previous by thread: Re: ASP.net XML Encoding
- Next by thread: Re: How to share VB code across multiple pages?
- Index(es):
Relevant Pages
|
Loading