transfer data from one asp page to second page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • coachdave
    New Member
    • May 2007
    • 10

    transfer data from one asp page to second page

    Hi, all! Need to transfer some data - 20 characters or less, from a first asp page that is called by a user submitting a form on an html page. What downloads from this first asp page is affected by what the user submits. Usually it includes another form which, when the user fills out and submits, calls a second asp page and this, after putting the data through a regex, stores it in a cgi-bin file. This all works: BUT I need to get some data from the first page to the second to be stored along with the data there.
    I have tried hidden inputs on the form send down from the first page, and also including client-side javascript on it, it executes on the client side and could fill in a hidden input - but it doesnt know what data the server side asp/javascript has. Is there a way to send data from the first page directly to the second? Or a way to get the server-side asp/javascript to fill out the hidden input field on the form before it downloads?
    The server I am using is www.sti.net, it runs asp and Jscript, so the first line of code is always:
    <%@Language=JSc ript%>
    and there then follows all the html containing the meta, title, css, and so on, then the <% and the Request.Form statements that receive the form upload from the user on the html page. That all works.
    Hoping for some suggestions! Dave
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    Try for the session variables though it may not be very effiecient
    or the querystrings if the data is very less.

    Comment

    • coachdave
      New Member
      • May 2007
      • 10

      #3
      Originally posted by shweta123
      Hi,

      Try for the session variables though it may not be very effiecient
      or the querystrings if the data is very less.
      Shweta,
      This may sound stupid but I dont know what the session variables are, nor the querystrings.
      I have another question,, and maybe the answer to it may give me a way to get the data from page to page. On the second page that I mention, I store data in a cgi-bin file. I use:
      Code:
         filename=Server.MapPath("cgi-bin/myfile.txt");
         fs=Server.CreateObject("Scripting.FileSystemObject");
         replies=fs.OpenTextFile(filename,8,true);
          replies.WriteLine(cleanqsubm);
          replies.Close();
      and that appends a line of text onto the file, or creates the first line if the file is empty. NOW what I want to do is, at the beginning of the page, read that last line in to recover an order number from the previously stored line, to increment so that each line has its own orrder number. What code would I write to do that?
      Hoping someone can help an asp neophyte,
      Coachdave

      Comment

      • shweta123
        Recognized Expert Contributor
        • Nov 2006
        • 692

        #4
        Hi,

        Hope you still need this,
        You can create session variable by
        <%
        Session(variabl ename)=value
        %>
        Now this variable can be referred on any of your asp pages.

        Similarly querystring can be used while calling the page.
        e.g. <a href=default.as p?var1="someval ue">GoNext</a>

        For your second question,do you want to read the last line from the file and you are not able to do that?
        Please refer this
        Link
        for File processing.

        Comment

        • coachdave
          New Member
          • May 2007
          • 10

          #5
          Originally posted by shweta123
          Hi,

          Hope you still need this,
          You can create session variable by
          <%
          Session(variabl ename)=value
          %>
          Now this variable can be referred on any of your asp pages.

          Similarly querystring can be used while calling the page.
          e.g. <a href=default.as p?var1="someval ue">GoNext</a>

          For your second question,do you want to read the last line from the file and you are not able to do that?
          Please refer this
          Link
          for File processing.
          shweta123,
          thank you for the informtion about FSO on that website classicasp.aspf aq. With the help of it, I was able to write code that could read from the file and extract the last line there. Right now I am struggling a problem trying to write to the file: I get 'permission denied, 800a0046' errors. Strange, I can read the file, and read AND write to another file. But not write to that one. I am corresponding with support on my ISP on that.
          But, about the session variable: I tried that, I write
          Session(transin fo) = qhname
          where qhname is the information I have to transfer and transinfo is the name
          of that information to use in the second asp page. BUT, I get the error
          message: "transinfo is undefined".
          If I can get the file reading and writing thing working I dont need the session variable here, but it would be nice to know how to make session variables work.
          Dave

          Comment

          • shweta123
            Recognized Expert Contributor
            • Nov 2006
            • 692

            #6
            Hi,
            You are getting 'Permission Denied' may be because of Access Rights. Set the Write Acess on the folder in which file is residing.Also close the filesystem object as soon as you finish any Read or Write operation and then reopen it for the next operation.
            For storing a value in a Session variable , write it like this
            Session("transi nfo") = qhname




            Originally posted by coachdave
            shweta123,
            thank you for the informtion about FSO on that website classicasp.aspf aq. With the help of it, I was able to write code that could read from the file and extract the last line there. Right now I am struggling a problem trying to write to the file: I get 'permission denied, 800a0046' errors. Strange, I can read the file, and read AND write to another file. But not write to that one. I am corresponding with support on my ISP on that.
            But, about the session variable: I tried that, I write
            Session(transin fo) = qhname
            where qhname is the information I have to transfer and transinfo is the name
            of that information to use in the second asp page. BUT, I get the error
            message: "transinfo is undefined".
            If I can get the file reading and writing thing working I dont need the session variable here, but it would be nice to know how to make session variables work.
            Dave

            Comment

            • coachdave
              New Member
              • May 2007
              • 10

              #7
              shweta123,
              I want to thank you for your help with the session variable thing. Using the quotes you specified, I was able to get data transferred from a first to a second page with session variables.
              I still need to read the last line of a cgi-bin file in one of the applications I have, and I still have yet to hear from the 'network guys' at STI about why I am getting the
              'permission denied' errors when I try to WRITE to the file. You mentioned checking the 'access rights' on the folder that the file is in, that would be cgi-bin on my server. How would I go about doing that?
              Dave

              Comment

              • shweta123
                Recognized Expert Contributor
                • Nov 2006
                • 692

                #8
                Hi,

                You can put IUSR_<machine_n ame> user into Administrator group if your application security permits that. You can do this by Going into Computer Management/User/Right click Properties and Select appropriate group.
                Also please refer this Thread
                for more details.

                Thanks

                Comment

                • coachdave
                  New Member
                  • May 2007
                  • 10

                  #9
                  Shweta,
                  you are'nt going to believe this, but the 'permission denied' problem turned out to be just a stupid syntax error. I had
                  tcmfile=Server. MapPath(cgi-bin.myfile.... when it should have been
                  cgi-bin/myfile...
                  Anyway, the 'network guys' at sti finally got me straightened out on that.
                  I have another problem related to the first, and on the same asp pages. I want to send a short string to be stored on a cookie on the client's computer. I have javascript to write the cookie, and read it. My problem is getting the data from asp to the client-side javascipt.
                  What I have been doing, and it isn't working, is sending a form down to the client with a hidden input. The html is within Response.Write statements, because there are some conditions where I would not send the data down and write a cookie. So I have
                  var cookiedata=qnam e+ etc.
                  Response.Write( "<form name='fame' method= etc. ");
                  Response.Write( "<input type='hidden' name='fin' value=cookiedat a />");
                  (note - no quotes around cookiedata.) then, after the %>,
                  <script type="text/javascript" language="javas cript">
                  var cqname=document .fame.fin.value ;
                  document.cookie ="History="+cqn ame+"; expires etc.
                  but, what gets stored in the cookie is the word cookiedata, rather than the VALUE of cookiedata that asp had calculated.
                  So how can I get this method, or some other method, to work to get the snippet of data into the cookie?. Typically the data is 10-20 characters.
                  hthfys,
                  Coachdave

                  Comment

                  Working...