Name

Get

Synopsis

Application.Get(ByVal name As String)
Application.Get(ByVal Index As Integer)

Gets an element of the Application collection either by name or ordinal position (index) within the Application collection. Generally, the name is used in calls to Get unless you need to get members of the collection inside a loop.

Parameters

name

A variable of type String that specifies the name of the item to be retrieved from the Application collection.

Index

A variable of type Integer that specifies the index of the item to be retrieved from the Application collection.

Example

The example below sets and gets a value from the Application collection. It also uses the Get method to write a message to the Text property of the Message control that includes the current value of the newly added element of the Application collection.

Sub Page_Load(  )
   Application("GetTest") = "Got it!"
   Message.Text = "GetTest = " & Application.Get("GetTest")
End Sub

Notes

You can see whether a named value is saved in the Application collection by checking to ensure that its value is not null, as shown in the following code:

If Not Application("Foo") is Nothing then
   Message.Text = "Foo is set to " & Application.Get("Foo")
End If

Get ASP.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.