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!

Anomalie with session variables

Status
Not open for further replies.

AlpineKJB

Programmer
Dec 15, 2000
17
US
PageA:

Comment = session.contents.item("Comment")
%>

<form name=&quot;myform&quot; action=&quot;PageB&quot;
<TEXTAREA name=&quot;Comment&quot;><%=Comment%></TEXTAREA>


PageB:

session.contents.item(&quot;Comment&quot;) = request.form(&quot;Comment&quot;)

The user enters a comment and clicks submit. On PageB, the comment is assigned to a session variable. The user cancels and returns to pageA. The session variable (which now has the origin comment) is captured and reassigned to the forms textbox so that the visitor does not have to retype it.

HOWEVER, the above (PageA) does not work. The comment is not reassigned. That is... unless I access the variable &quot;Comment&quot; prior to the form:


PageA:

Comment = session.contents.item(&quot;Comment&quot;)
If Comment = &quot;&quot; then
'do absolutely nothing
End If
%>

When I add the If statement, everything starts working. A really wacko anomalie. Has anyone encountered this before? Can it be explained or is it a bug with ASP?

-KJB


 
Hi KJB

Try it this way...after you write out the error on PageA clear the Session variable...because if you call it on other pages, all the Session variable will be still all in there..i found it doing this way a lot better...

PageA:

<form name=&quot;myform&quot; action=&quot;PageB&quot;
<TEXTAREA name=&quot;Comment&quot;><%
Response.Write(Session(&quot;Comment&quot;))
Session(&quot;Comment&quot;) = &quot;&quot;%></TEXTAREA>


PageB:

Session(&quot;Comment&quot;) = Request.Form(&quot;Comment&quot;)

hope this helps...

hui
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top