Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 9th, 2005, 01:29 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default Is it possible for me using session variables into

Hello:
I have a class where I’m using session variables, notwithstanding when I compile Project it’s sending me this error: “Name ‘session’ doesn’t exist in class or namespace ‘WUC_CreDes.Class1’”.
Does it mean that it is not permitted to me using session variables into a class?
This is my code:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace WUC_CreDes
{
    public class Class1
    {
        public static bool No_PostBack()
        {
            Session["par1"] = "";
            return false;
        }
    }
}

Thank you in advance for your help.

A.L.

El Hombre que tiene Amigos ha de mostrarse Amigo
__________________
El Hombre que tiene Amigos ha de mostrarse Amigo
  #2 (permalink)  
Old March 9th, 2005, 02:07 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

   You cannot see Session vaiables from a class. I don't know the technical reason why that is. I have gotten around the problem by passing the session variable value to the function or sub in the class.
  #3 (permalink)  
Old March 9th, 2005, 04:06 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cairo, , Egypt.
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alyeng2000
Default

you could as
HttpContext.Current.Session["Part1"]="";

Ahmed Ali
Software Developer
  #4 (permalink)  
Old March 9th, 2005, 06:00 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

great call Ahmed.. I didn't realize you could do that

good to know!!!
  #5 (permalink)  
Old March 9th, 2005, 07:46 PM
Authorized User
 
Join Date: Dec 2004
Location: Mexico City, , Mexico.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks you Ahmed:
Now it’s working.
...with your help.

El Hombre que tiene Amigos ha de mostrarse Amigo
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Variables in C# shikha09 C# 1 November 28th, 2006 10:38 AM
Session Variables testsubject Visual Studio 2005 8 March 8th, 2006 04:26 PM
Session Variables - help? Annoyamouse BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 11 August 31st, 2004 03:56 PM
Session Variables flesh_god Dreamweaver (all versions) 7 November 11th, 2003 05:52 PM
session variables help face Classic ASP Databases 4 September 12th, 2003 03:57 PM



All times are GMT -4. The time now is 06:39 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.