Skip to main content
June 12, 2008
Answered

Session Variable in Insert Record

  • June 12, 2008
  • 3 replies
  • 399 views
I am using the Insert Record server behavior to add records to a database. What I want to do is have the user select their name from a list when they first come to the site. Then I want to remember that value so that every single time they enter a new record, they don't have to pick their name from the drop down. Instead, the application would just insert that variable it got from the first page, and insert it into the Name field wherever it needs to. Was thinking a session variable could help do this, but not sure. Can someone point me in the right direction?
This topic has been closed for replies.
Correct answer Newsgroup_User
>I am using the Insert Record server behavior to add records to a database.
> What I want to do is have the user select their name from a list when they
> first come to the site. Then I want to remember that value so that every
> single time they enter a new record, they don't have to pick their name
> from
> the drop down. Instead, the application would just insert that variable it
> got
> from the first page, and insert it into the Name field wherever it needs
> to.
> Was thinking a session variable could help do this, but not sure. Can
> someone
> point me in the right direction?


You're on the right track.

On your first page:
<% Session("Username") = Request.Form("Username") %>

Then, on the page with the Insert Record behavior, add a hidden field with
the value:
<%=Session("Username")%>

Or in a form with the Username field, set the default value to:
<%=Session("Username")%>

3 replies

Participating Frequently
June 17, 2008
thanks for the info
Inspiring
June 13, 2008
>
> On your first page:
> <% Session("Username") = Request.Form("Username") %>



More....
Set the form action = page2.asp, form method = post, then put that line of
code on page2.asp.

Newsgroup_UserCorrect answer
Inspiring
June 13, 2008
>I am using the Insert Record server behavior to add records to a database.
> What I want to do is have the user select their name from a list when they
> first come to the site. Then I want to remember that value so that every
> single time they enter a new record, they don't have to pick their name
> from
> the drop down. Instead, the application would just insert that variable it
> got
> from the first page, and insert it into the Name field wherever it needs
> to.
> Was thinking a session variable could help do this, but not sure. Can
> someone
> point me in the right direction?


You're on the right track.

On your first page:
<% Session("Username") = Request.Form("Username") %>

Then, on the page with the Insert Record behavior, add a hidden field with
the value:
<%=Session("Username")%>

Or in a form with the Username field, set the default value to:
<%=Session("Username")%>