Highlighted
Micro Focus Contributor
Micro Focus Contributor
1303 views

How to set and retrieve a session variable for a current Web Form in ASP.NET - A simple example

Jump to solution

[Migrated content. Thread originally posted on 04 February 2011]

In Visual COBOL R3:


Setting a value

$ilusing "System.Web"
$ilusing "System"

01 myString String.
...
...
set myString to textBox1::Text
set Self::Session::Item("VarKey1") to myString


Retrieving a Value:

$ilusing "System.Web"
$ilusing "System"


01 myString String.
...
...
try
    set myString to Self::Session::Item("VarKey1")
catch
    set LabelStatus::Text to exception-object::Message
end-try

NOTE: The Visual COBOL R3 example makes use of a built in exception-object that is automatically generated to catch an exception in a Try-Catch block.



In NetExpress for .NET:

Setting a Value

$ilusing "System.Web"
$ilusing "System"

01 myString String.
...
...

set myString to textBox1::"Text"
set Self::"Session"::"Item"("VarKey1") to myString


Retrieving a Value:

$ilusing "System.Web"
$ilusing "System"

01 myString String.
01 NullEx Type "NullReferenceException".
...
...
try
    set myString to Self::"Session"::"Item"("VarKey1") 
catch NullEx
    set LabelStatus::"Text" to "Entry Not Found..."
end-try
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: How to set and retrieve a session variable for a current Web Form in ASP.NET - A simple example

Jump to solution
0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: How to set and retrieve a session variable for a current Web Form in ASP.NET - A simple example

Jump to solution
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.