Name

GetKey

Synopsis

Application.GetKey(ByVal Index As Integer)

Retrieves the key name corresponding to the index of a data item stored to the Application object.

Parameters

Index

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

Example

The example removes all values from the Application collection in order to start from a known state. Next, it writes a single value to the Application collection. Finally, it saves the key from the first element (index 0) retrieved by a call to GetKey into the Message control.

Sub Page_Load(  )
   Application.RemoveAll(  )
   Application("GetKeyTest") = "Got it!"
   Message.Text = "Key of Application(0) = " & _ 
                   Application.GetKey(0) & _
                   "<br/>(Should be GetKeyTest)"
End Sub

Notes

If Index is less than 0 or greater than Application.Count - 1, an ArgumentOutOfRangeException exception will be thrown.

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.