Store Textfield value in Session variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PLA2000
    New Member
    • Mar 2008
    • 2

    Store Textfield value in Session variable

    I want to store a value that I enter in a textfield in a session variable to use on another page without submitting the value to a data table.

    I tried:

    <% Session(“firstn ame”)= Request.Form(“F irst”) %>

    I also tried:

    <% Session(“firstn ame”)= First.Text %>

    Neither worked but

    <% Session(“firstn ame”)= "John" %>

    does work and the value is available on subsequent page.

    Please help,

    Peter A
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Peter,

    Welcome to Bytes.com! I hope you find the site useful.

    Have you tried outputting the value of Request.Form(“F irst”) to the page? You'll probably find that the value isn't being passed correctly as otherwise I would expect it to be stored in the session variable with your first bit of code. Use a Response.Write Request.Form(“F irst”) to see what it contains.

    Let me know how it goes,

    Dr B

    Comment

    • PLA2000
      New Member
      • Mar 2008
      • 2

      #3
      DrB,

      Thanks for the tip. Form("First") does not return any value. I'll try some other ways to capture the value in the session variable.

      Peter

      Originally posted by DrBunchman
      Hi Peter,

      Welcome to Bytes.com! I hope you find the site useful.

      Have you tried outputting the value of Request.Form(“F irst”) to the page? You'll probably find that the value isn't being passed correctly as otherwise I would expect it to be stored in the session variable with your first bit of code. Use a Response.Write Request.Form(“F irst”) to see what it contains.

      Let me know how it goes,

      Dr B

      Comment

      • deric
        New Member
        • Dec 2007
        • 92

        #4
        Hi...
        I think it will really not output anything because the textfield "First" doesn't exist in the previous page. Request.Form() will get a value from the querystring or from the previous page that called this current page.
        In order for you to set the value of the session variable, you need to submit the page and do the setting of the session on the receiving page.

        Can you try to check if this will work: place <% Session(“firstn ame”)= Request.Form(“F irst”) %> at the end of the source code. I have not actually tried it, and Im not able to try it at this moment coz I dont have access to an ASP server right now. ;(

        Comment

        Working...