Share via


Session State Management Service Example

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Expanding on the Notification Service Example, when the Web Part, Picture of Car, displays the selected car, it must make the name of the selected car available to the Web Part, Get Sales Information. When the user navigates to the purchasing dashboard to place an order, the selected car is retrieved and displayed.

To accomplish this, Picture of Car uses the PutSessionState function, specifying the namespace URN, the name of the value to save, and the actual value associated with that name:

<SCRIPT language="JScript" id=s1>
function DisplayCarInfo(sCarSelected)
{
   switch (sCarSelected) {    
…
   }  
      DDSC.PutSessionState("urn:myCompany:Car", "SelectedCar", sCarSelected);
}
</SCRIPT>

When the purchase dashboard is initialized, the Web Part, Purchase Car, retrieves the stored session state using the GetSessionState function, specifying the namespace URN and the name of the value to display. Then, it adds the name of the selected car to the purchase form:

<TABLE border=0 cellPadding=1 cellSpacing=1 style="HEIGHT: 228px; WIDTH: 415px" width="75%">
 <TR>
    <TD>Selected Car:</TD>
    <TD><INPUT DISABLED="1" ID="CarsForSale" NAME="CarsForSale" SIZE="30"></TD></TR>
…
</TABLE>
<SCRIPT LANGUAGE=javascript>
CarsForSale.value = DDSC.GetSessionState ("urn:myCompany:Car", "SelectedCar");
</SCRIPT>

See Also

Session State Management Service