How do declare a public variable .aspx
web page that can be used in all the pages within my web application?
And/or create a Public Sub
?
How do declare a public variable .aspx
web page that can be used in all the pages within my web application?
And/or create a Public Sub
?
A public sub, assuming you use VB:
Public Sub MyOwnSub()
'do something'
End Sub
A global variable: add a module to your VB and add a variable to that module. You can call that variable with ModuleName.VariableName
from everywhere.
When you declare a public variable in the code-behind of your ASPX page, and you declare it shared, you can access it with YourPageName.VariableName
from anywhere in your web application. Note that this variable is shared between all processes or requests.
Public Shared VariableName As String = "hello world"
You can use Session or Application state to hold global data needed for your website.
Maybe you can work with ViewState to persist values into the session.
I think that isn't possible to create 'global variables', since the value is lost at every page load...
ViewState["key"] = variable;
variable = ViewState["key"];