By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,759 Members | 1,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,759 IT Pros & Developers. It's quick & easy.

Losing session variable in popup

P: n/a
Hi,

This isn't a mission critical question but I thought I'dl throw it out there
for your feedback as it's a bit curious.

I have developed a shopping cart for an application I'm working on which is
loosely based on the e-commerce example in the quickstarts tutorial.

In the cart display I have provided functionality so that when a user clicks
on a product name a popup is opened with the full product details displayed.
Baiscally, a javascript function with the product id as an argument opens
the popup windw with the product id in the querystring so that I can display
the product details in the popup.

It then occured to me that it would be nice to provide a dropdown list in
the popup window to dsiplay the other itmes in the cart so that the user
could view the details of any of the other cart items by selecting it from
this list.

Now, my shopping cart values are stored in a session variable of a type that
exposes the icollection interface - the cart display itself is simply a
datalist databound to this icollection so I figured that I should be able to
do the same with and bind the dropdownlist.

However, when I tried my dropdown remained empty and after some detective
work I discovered that it was because my session variable appeared to be
empty in the popup page despite the fact that the shopping cart page could
read it without any problem.

So, my question is about the scope of session variables really I suppose -
does anyone have any thoughts about why my session variable wouldn't be
available to the popup window?

I look forward to hearing your thoughts,

Joe

Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Joe
Can you please post the relevent sample code? specifically, the code that
generates the pop-up and then the code in the pop-up itself.

"Joe Molloy" <mo********@hotmail.com> wrote in message
news:eh**************@TK2MSFTNGP09.phx.gbl...
Hi,

This isn't a mission critical question but I thought I'dl throw it out there for your feedback as it's a bit curious.

I have developed a shopping cart for an application I'm working on which is loosely based on the e-commerce example in the quickstarts tutorial.

In the cart display I have provided functionality so that when a user clicks on a product name a popup is opened with the full product details displayed. Baiscally, a javascript function with the product id as an argument opens
the popup windw with the product id in the querystring so that I can display the product details in the popup.

It then occured to me that it would be nice to provide a dropdown list in
the popup window to dsiplay the other itmes in the cart so that the user
could view the details of any of the other cart items by selecting it from
this list.

Now, my shopping cart values are stored in a session variable of a type that exposes the icollection interface - the cart display itself is simply a
datalist databound to this icollection so I figured that I should be able to do the same with and bind the dropdownlist.

However, when I tried my dropdown remained empty and after some detective
work I discovered that it was because my session variable appeared to be
empty in the popup page despite the fact that the shopping cart page could
read it without any problem.

So, my question is about the scope of session variables really I suppose -
does anyone have any thoughts about why my session variable wouldn't be
available to the popup window?

I look forward to hearing your thoughts,

Joe


Nov 18 '05 #2

P: n/a
Your query sounded like something I might like to do, so I gave it a try.
The following worked for me.

I created two aspx pages, PopUpTest.aspx and PopUpItem.aspx. The pertinent
code for both pages is below.

When PopUpText.aspx loads, three session variables are set as seen in the
code. Then when you click the button on the page, JavaScript is run to open
the page PopItem.aspx in a new, sized window. On PopItem.aspx is a label
containing the value for Session("PopUpTest_Name") and a dropdown list box
containing two items with values Session("Item1") and Session("Item2") .

------------------------

Code on PopUpTest.aspx :

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Session("PopUpTest_Name") = "Testing Session Variables"
Session("Item1") = "A " & Now.ToString
Session("Item2") = "B " & Now.ToString
End Sub

Private Sub btnPopUp_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPopUp.Click
Dim scriptString As String
'scriptString = "<script language=JavaScript>
window.open('PopUpItem.aspx')"
scriptString = "<script language=JavaScript>
window.open('PopUpItem.aspx','test','width=500,hei ght=400,resizable=yes,scro
llbars=yes');"
scriptString = scriptString & "test.focus();"
scriptString = scriptString & "</script>"
RegisterStartupScript("newwindow", scriptString)
End Sub
---------------------------

Code on PopUpItem.aspx:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.Label1.Text = "Session Variable 'PopUpTest_Name' has value: " &
Session("PopUpTest_Name")
Me.DropDownList1.Items.Clear()
Me.DropDownList1.Items.Add(Session("Item1"))
Me.DropDownList1.Items.Add(Session("Item2"))
End Sub

"Joe Molloy" <mo********@hotmail.com> wrote in message
news:eh**************@TK2MSFTNGP09.phx.gbl...
Hi,

This isn't a mission critical question but I thought I'dl throw it out there for your feedback as it's a bit curious.

I have developed a shopping cart for an application I'm working on which is loosely based on the e-commerce example in the quickstarts tutorial.

In the cart display I have provided functionality so that when a user clicks on a product name a popup is opened with the full product details displayed. Baiscally, a javascript function with the product id as an argument opens
the popup windw with the product id in the querystring so that I can display the product details in the popup.

It then occured to me that it would be nice to provide a dropdown list in
the popup window to dsiplay the other itmes in the cart so that the user
could view the details of any of the other cart items by selecting it from
this list.

Now, my shopping cart values are stored in a session variable of a type that exposes the icollection interface - the cart display itself is simply a
datalist databound to this icollection so I figured that I should be able to do the same with and bind the dropdownlist.

However, when I tried my dropdown remained empty and after some detective
work I discovered that it was because my session variable appeared to be
empty in the popup page despite the fact that the shopping cart page could
read it without any problem.

So, my question is about the scope of session variables really I suppose -
does anyone have any thoughts about why my session variable wouldn't be
available to the popup window?

I look forward to hearing your thoughts,

Joe


Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.