473,322 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Public functions and variables

Hi

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

Thanks

Regards
Feb 11 '07 #1
5 1831
On Feb 11, 3:41 am, "John" <J...@nospam.infovis.co.ukwrote:
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

--
http://ajaxwidgets.com
Free ASP.NET Ajax Widgets NOW!

Feb 11 '07 #2
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;
}
"John" <Jo**@nospam.infovis.co.ukwrote in message
news:eV**************@TK2MSFTNGP02.phx.gbl...
Hi

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

Thanks

Regards
Feb 11 '07 #3
For simplicity's sake, you can create public static ("Shared" in vb.net)
methods in the Global.asax class. Then any page can access these methods with:

Global.MethodName(parameterValue...)

Peter

Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"John" wrote:
Hi

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

Thanks

Regards
Feb 11 '07 #4
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

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:3B**********************************@microsof t.com...
For simplicity's sake, you can create public static ("Shared" in vb.net)
methods in the Global.asax class. Then any page can access these methods
with:

Global.MethodName(parameterValue...)

Peter

Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"John" wrote:
>Hi

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

Thanks

Regards

Feb 11 '07 #5
Global.ASP.global_asax.MyFunction(Now, "dd/mm/yyyy hh:mm:ss")

--
Milosz
"John" wrote:
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

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:3B**********************************@microsof t.com...
For simplicity's sake, you can create public static ("Shared" in vb.net)
methods in the Global.asax class. Then any page can access these methods
with:

Global.MethodName(parameterValue...)

Peter

Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"John" wrote:
Hi

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

Thanks

Regards


Feb 12 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
9
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
3
by: Parintas Themis STE Kardias | last post by:
Hi How can i use public variables. These variables i wand to use in different places on a form (like a button) and are neccessery to write the type of variable like: Public VAR1, var2 as integer...
5
by: Tee | last post by:
Hi, In VB, we can add a module to put all the variables and functions, do we have something similar in C#? Thanks
6
by: darrel | last post by:
I'm still not quite sure how best to handle the passing of data between controls. This is a method I'm using at the moment: I have an XML file that contains a variety of page-centric...
8
by: Floris van Haaster | last post by:
Hi All! I have a question, i have a web application and I store some member information in a variable i declared in a module like: Public some_info_variable as string in module1.vb But...
27
by: thomasp | last post by:
Variables that I would like to make available to all forms and modules in my program, where should I declare them? At the momment I just created a module and have them all declared public there. ...
5
by: Steve Mauldin | last post by:
Having weird things happening with my code. Two users on at the same time and data entered by one user is added into another users global variable. global variable data being stored in session...
86
by: jopperdepopper | last post by:
Hi, finally giving php 5 a go, and going over the new approach to classes. Can someone clarify the public, private and protected to me? I quote the php manual: "The visibility of a property or...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.