Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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 September 14th, 2006, 02:55 PM
Authorized User
 
Join Date: Aug 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to KamalRaturi Send a message via Yahoo to KamalRaturi
Default Can we get value of a session variable

Can we get value of a session variable in .vb class) file.
Actully It gives error.

the prob is following:

file name SessionString.vb // In Bussiness layer
------------------------------------------
string myString()
{
return Session("A")+Session("B")+Session("C");
}
--------------------------------------------


from .aspx.vb I Call it as
------------------
StrSession=SessionString.myString()
-----------------

Red word is giving error
is there another option if u kno pls tell me

Thanks in advance
--------

Edited: .Vb shud be read as .cs.
 
Old September 14th, 2006, 03:07 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

How do you have C# code inside a .vb class and vb code in the aspx.vb page?

You cant use Session in a class file nor can you use application variables (not directly anyway) use
HttpContext.Current.Session(variable)



"The one language all programmers understand is profanity."
 
Old September 14th, 2006, 03:08 PM
Friend of Wrox
 
Join Date: Feb 2006
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The session array is an Object array, so when you use the contents of that array to say, add integers, or concatenate strings, you have to convert it to the type necessary for that operation. So if you had two strings stored in the session array, you would need to use CStr(Session("A")) & CStr(Session("B")) because the concatenate operator only works on strings, and not objects.

Neil Timmerman
Programmer
Veris Consulting
 
Old September 14th, 2006, 03:33 PM
Authorized User
 
Join Date: Aug 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to KamalRaturi Send a message via Yahoo to KamalRaturi
Default

thanks deParsons and thenoseknows.

Ur Solution(s) has worked.
 thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
session and variable... badboy1 ASP.NET 3.5 Basics 1 August 3rd, 2008 09:14 AM
Session Variable youyou_hym Dreamweaver (all versions) 4 January 20th, 2005 11:48 AM
Session variable anuradha80 General .NET 3 November 4th, 2004 12:39 AM
Session variable mrideout BOOK: Beginning ASP.NET 1.0 1 August 12th, 2004 07:01 PM





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