Public functions and variables

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

Is there a way to declare public functions that can be accessed in any aspx
page? Can global variables be declared?

Thanks

Regards
 
Hi

Is there a way to declare public functions that can be accessed in any aspx
page? Can global variables be declared?

Read up on "Singleton"...
You'd probably find a zillion implementations at google if you combine
your search with C# or something...!!

..t
 
Within the code-behind of the .aspx page, you can create public methods and
properties. The page should have access to them: <#% GetCurrentTime() %>
will work if you have a public method like:

public DateTime GetCurrentTime()
{
//add code here to return DateTime value;
}
 
Thanks for that. I have created the function in Global.asax file in the
site root as follows;

script language="VB" runat="Server">
Shared Function MyFunction(ByVal d As Object, ByVal pat As Object) As Object

End Function
</script>

However when I use it in one of my pages as below;

MyVar = Global.MyFunction(Now, "dd/mm/yyyy hh:mm:ss")

I get an '"MyFunction is not a member of '<default>' error. What am I doing
wrong?

Thanks

Regards
 

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