Public functions (asp.net 2.0/vb.net 2005)

  • Thread starter Thread starter Igor
  • Start date Start date
I

Igor

I have many aspx pages and on every page i must call one function. I don't
want to write or copy paste this function on all pages. How can I create one
function in some new module and use this function on all aspx pages?

Thanx
 
Are you talking about server-side or client-side function?

If it is a server-side one, make a class in a separate file and call it from
all pages.

If it is a client-side one, make a separate file with the javascript for the
function and link to this file from all pages.
 
Are you talking about server-side or client-side function?
If it is a server-side one, make a class in a separate file and call it
from all pages.

In this function I must translate something. It is something like:

Public function Translate(byVal word as string, language as string)
...code for reading from access file...
Translate=TranslatedText
End function


It is in class myFunctions.vb!
I have problem if I call this function from some aspx page like:
Text=Translate(Word)

Message is: "Reference to a non-shared member requires an object reference."
What is the problem. How to fix it?
 
If it is not declared as shared, you have to create an object and call the
function via the object reference. If it is shared, you call it via a class
reference. You need to read a bit about this stuff.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top