I have an aspx app that uses several variables that are maintained in
Session variables. I wanted to cut down on the code to maintain
initialize and save the variables between server calls. I really like to
be able to reference the name of a variable but (unless something's
changed that I don't know about) that's not going to happen.
So, I came a class like with the following:
Public Amount() As String = {"", "Amount"}
Public Term() As String = {"","Term"}
Public Sub Initialize()
GetStringData(Amount)
GetStringData(Term)
End Sub
Public Sub Save()
SaveStringData(Amount)
SaveStringData(Term)
End Sub
Private Sub SaveStringData(ByVal str() As String)
If str(1) = Nothing Then
Return
End If
Session(str(1)) = str(0)
End Sub
Private Sub GetStringData(ByRef str() As String)
If str(1) = Nothing Then
str(0) = ""
Else If IsNothing(Session(str(1))) Then
str(0) = ""
Else
str(0) = Session(str(1))
End If
End Sub
What I really want is a quick method of saving the variable in a session
variable of the same name (ie. var "Term" has a corresponding
Session "Term"). Maybe no one will like the above method but it seems to
work well and has significantly cut down my code.
Anyone have any other ideas or suggestions????
Thanks...Jim