944,127 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 3474
  • ASP.NET RSS
Sep 23rd, 2007
0

Session variables

Expand Post »
I wonder if anyone can help with this problem I have

I'm trying to create a shopping cart with session variables, there are 5 buttons on the form and by clicking 1 of these displays the relevant product and price in session variables in textboxes on the next form, the product list is in an XML file, I can load 1 selection fine but can't seem to load the session variables for the other buttons depending on what button is clicked

Does anybody have any tips/advice on how to overcome the problem

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
SLG29 is offline Offline
4 posts
since Sep 2005
Sep 23rd, 2007
0

Re: Session variables

I would not recommend using the Session command for storing product related information

I would use the query string
ie. http://www.taylorsnet.co.uk/SourceCo...spx?SourceID=5

So that if a customer bookmarks that page it will forget the session but will still retain the info from the query string

the page can access the query string from
ASP.NET Syntax (Toggle Plain Text)
  1. request("productid")
Then get the product page to pull the data from the XML file

multiple query strings can be added by separating them by a &
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Sep 23rd, 2007
0

Re: Session variables

Thanks for the reply

This is an assignment I'm doing and the requirement is for session variables, as you're saying you wouldn't normally do this in the real world

Is there a way I can load the session variables depending on what button is clicked on the first form

Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
SLG29 is offline Offline
4 posts
since Sep 2005
Sep 23rd, 2007
0

Re: Session variables

In this case I would have a common session variable

On first page
ASP.NET Syntax (Toggle Plain Text)
  1. public sub button1_click
  2. session("Clicked") = "button1"
  3. end sub
  4.  
  5. public sub button2_click
  6. session("Clicked") = "button2"
  7. end sub
  8.  
  9. public sub button3_click
  10. session("Clicked") = "button3"
  11. end sub

On second page
ASP.NET Syntax (Toggle Plain Text)
  1. public sub page_load
  2. if session("Clicked").tostring = "button1" then
  3. 'run these sessions
  4. elseif session("Clicked").tostring = "button2" then
  5. 'run these sessions
  6. elseif session("Clicked").tostring = "button3" then
  7. 'run these sessions
  8. else
  9. response.redirect("firstpage.aspx")
  10. end if
  11. end sub
  12.  
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Sep 23rd, 2007
0

Re: Session variables

Thank-you for your help, the products and prices are appearing in the textboxes now, to complete the assignment I need to do the following:

On the order form with the relevant product and price in the textboxes a quantity is entered, when add to basket link is clicked the user is taken to the shopping basket form which is the last form in the application showing the contents of their order, (Description, price, quanity and total) in a datagrid with a text box also showing the order value

The user can then either click place order, this then results in an email being sent with the order details and taken to a conformation page, the basket should then be cleared

The other option is to click carry on shopping, the user is then taken back to the products page and allowed to add further contents to the shopping basket

Any tips/advice on how to approach this would be appreciated, I'm not looking to be spoon fed the answer, just need a guide being new to the language

Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
SLG29 is offline Offline
4 posts
since Sep 2005
Sep 23rd, 2007
0

Re: Session variables

To send E-Mails lookup these Variables

Dim EMail As New System.Net.Mail.MailMessage
Dim SMTPServer As New System.Net.Mail.SmtpClient
Dim Authentication As New Net.NetworkCredential("login name/email", "password")


The rest is quite easy once you know the Variables
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Hide Button when DataView is empty
Next Thread in ASP.NET Forum Timeline: Create and write a text file that saved in network folder





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC