Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 14th, 2004, 12:38 AM
Authorized User
 
Join Date: Jun 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Planoie,
  Let me Explain, i have a .ascx page wherein i assign a value for my Session Variable..let us say:
         Session.Add ("ssnStudentName","Twinkle");
And i have another .cs file, wherein i access the session variable, say:
           string strName = (string)System.Web.HttpContext.Current.Session["ssnStudentName"];
            System.Web.HttpContext.Current.Response.Write(strN ame);

This will result in a blank space without returning any value. It neither give erorr nor display the value.
Any Idea on this??
Thanks in Advance
Regards
Twinkle

 
Old June 14th, 2004, 07:32 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

No. I'm baffled. I have done this very same kind of operation myself and I have had success. Can you run this in the debugger to see that the code is working and see what's in the session? Try turning on trace for the page and look at the contents of the session collection to verify that your value is getting into the session.
 
Old June 17th, 2004, 04:34 AM
Authorized User
 
Join Date: Jun 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Planoie,
 I'm sorry I was wrong. It does raises Error (as I had handled the error, I couldn’t find out). When I debugged the code, I got the following errors in my immediate window

?System.Web.HttpContext.Current.Session["ssnStudentName"]
error: 'System.Web.HttpContext.Current.Session' is not an array or pointer. Indexing is not available
?(string)Session["ssnStudentName"]
error: identifier 'Session' out of scope
?(string)System.Web.HttpContext.Current.Session["ssnStudentName"]
error: 'System.Web.HttpContext.Current.Session' is not an array or pointer. Indexing is not available
?(string)context.Session["ssnStudentName"]
error: 'context.Session' is not an array or pointer. Indexing is not available

As of now I have overcome by using querysting instead of session. But I’m very much curious to know what was the problem actually. Thank You so much for ur support

Regards,
Twinkle


 
Old June 17th, 2004, 12:55 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ok, I realize now something that I should have caught earlier. You should try it this way:

System.Web.HttpContext.Current.Session.Items["..."]
 
Old June 18th, 2004, 07:03 AM
Authorized User
 
Join Date: Jun 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No planoie, I tried that long back..Even that didn't work, it gave a runtime error as follows
'System.Web.SessionState.HttpSessionState' does not contain a definition for 'Items'

 
Old June 18th, 2004, 08:04 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Well then I really don't know what the problem could be. Without seeing the entire picture of your code, the project and all I can't do much more.
 
Old June 23rd, 2004, 09:29 AM
Authorized User
 
Join Date: Jun 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

o.k No probs. have solved that using Querystring. Thank u so much






Similar Threads
Thread Thread Starter Forum Replies Last Post
Using classes seymour_glass C# 1 April 26th, 2007 10:18 PM
Session Variables in C# Classes rlb ASP.NET 2.0 Basics 3 April 5th, 2007 02:15 PM
classes dhoward VB.NET 2002/2003 Basics 2 November 8th, 2006 10:35 AM
session and cookie problem (empty session file) msincan BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 February 27th, 2005 05:31 PM
Get session values from a classes minhpx General .NET 3 August 9th, 2004 10:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.