ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1731
Number of posts: 3302

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Session State variable Posted by ceramicbrad on 21 Mar 2003 at 7:37 PM
This message was edited by ceramicbrad at 2003-3-21 19:40:6

I am having trouble understanding the reason why the following code works as a string:

******
Public sub button_click(byval sender as object,byval e as system.eventargs)handles button.click

Dim clicks as string
Session("Clicks") = Session("Clicks") + 1
response.write("# of clicks: " & session("clicks"))

end sub

********************************
But the following does not work as an integer:

******************************

public sub button_click(byval...)
Dim x as integer
Session(x) = Session(x) + 1
response.write("#:" & session(x))
end sub

********


any help to clear this issue would be appreciated...





Report
Re: Session State variable Posted by richpwelsh on 17 Apr 2003 at 7:57 AM
First of all, the declaration of the variables Dim clicks and Dim x have nothing to do with the Session objects.

To make this work try Session("x") += 1

This would increment the value of the Session object by 1.

All Session objects must be in quotes. You can declare the Session object in the global.asax file but that isn't aren't required.

Normally I do declare them to have a list of what I am using for Session objects.

Session("clicks") = ""
Session("x") = 0

Session objects can be of any datatype and the CLR figures out which to use by the data that's passed into it.

I hope that helps.




: This message was edited by ceramicbrad at 2003-3-21 19:40:6

: I am having trouble understanding the reason why the following code works as a string:
:
: ******
: Public sub button_click(byval sender as object,byval e as system.eventargs)handles button.click
:
: Dim clicks as string
: Session("Clicks") = Session("Clicks") + 1
: response.write("# of clicks: " & session("clicks"))
:
: end sub
:
: ********************************
: But the following does not work as an integer:
:
: ******************************
:
: public sub button_click(byval...)
: Dim x as integer
: Session(x) = Session(x) + 1
: response.write("#:" & session(x))
: end sub
:
: ********
:
:
: any help to clear this issue would be appreciated...
:
:
:
:
:
:

Report
Re: Session State variable Posted by ceramicbrad on 17 Apr 2003 at 9:29 AM
Thanks. Your comments cleared it up..

Brad




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.