472,373 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 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 6055
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.