Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use session property in a sub?

Status
Not open for further replies.

Riku

Programmer
Sep 2, 2001
119

Whats wrong with my code below?
Why can't sub read the session variable

sub CheckBoxAppliaction_click()
if session("CheckBoxAppliactionVar") = "1" then
session("CheckBoxAppliactionVar") = "0"
else
session("CheckBoxAppliactionVar") = "1"
end if
end sub

F: riku.tuominen@benchmarking.fi F: Riku Tuominen
riku.tuominen@benchmarking.fi
 
Is that misspelled on purpose
CheckBoxAppliactionVar
or should it be
CheckBoxApplicationVar?
Try putting a Response.Write (CheckBoxAppliactionVar)
in there to see if you are even getting there and what the value is.
Compare Code (Text)
Generate Sort in VB or VBScript
 
It was misspelled but that does not mather in this case.
I used same misspelled name on hole page.
Problem is that the code gives error.
I get message "error on page" on bottom of browser window. F: Riku Tuominen
riku.tuominen@benchmarking.fi
 
This code looks pretty suspicious.

The browser message about "error on page" is probably in the status line. This tells me we're dealing with a client-side error.

On top of that:
Code:
Sub CheckBoxAppliaction_click()
Makes me really wonder too.

It looks like it is meant to be an event handler. Of course, there is no click event in DHTML, the event you probably want is onclick.

But then, you have some ASP code intermixed here:
Code:
if session("CheckBoxAppliactionVar") = "1" then

So we have one of two things going on. Either you are trying to use ASP constructs on the client side (such as Session) or you are trying to use client-side constructs in your ASP code (such as event-handler subroutines).

Neither one of these works.

You can't click on something in the web page and invoke ASP code (barring making a new page request, or possibly using Remote Scripting technology).

You can't use Session variables in client code.
 
you may also want to turn on Option Explicit on your ASP page to make sure you don't misspell anything.

------------------------------------------------
- Replica Watches, Pen, Handbags, Jerseys and more
------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top