473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Losing session variable in popup

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
2 6140
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott Lyon | last post by:
I'm maintaining (read: I didn't write it, nor do I have the time to spend to rewrite it) an application that is suddenly giving me grief. The reason I say suddenly, is because we're in the...
2
by: Terry | last post by:
When launching our application with Internet Explorer already opened, but not pointing to our web server, the session variables disappear. If you open I.E. after launching our app, it works fine....
2
by: James | last post by:
Session("UserName") is set when someone logs in. Get to a page that displays a record where you can type a comment. The form has an onSubmit event that calls a javascript function. That function...
9
by: Jimmy Junatas | last post by:
When we open a window (using client-side jscript ie. window.open("/Site/Popup.aspx?...",...)) from Page1.aspx, the called page Popup.aspx does not have access to the Session variables present in...
4
by: Stephen | last post by:
I have a .NET (1.1 framework) application that is losing a session variable on only a few PC's. The main page is loading up in a frame in a Portal application. On the Page_Load it stores an...
4
by: Keith-Earl | last post by:
I have been writing ASP.NET apps since the RTM build and have never seen this. I built a simple app that uses session variables on my DEV laptop. All runs well. I have a simple toggle routine...
9
by: Adrian Parker | last post by:
We have a website that works everywhere but on a few PCs on this one site.. Asp.Net 1.1 Server = Windows 2003 Client = XP In the web.config we use - cookieless="false" in the browser settings...
0
by: Jimmy Reds | last post by:
Hi, Sorry if this appears twice but I post through Google Groups and it had a funny 5 minutes and didn't appear to post this message the first time. I am setting session variables on a page...
2
by: Jimmy Reds | last post by:
Hi, I am setting session variables on a page then doing a header/location redirect to a second page however I am losing one of my session variables. Not all of them, just one. Here are some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.