Request.Form & Arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James Baker

    Request.Form & Arrays

    I'm trying to use Request.Form to gather information in an array and I keep
    getting a type mismatch...not sure if it's even possible. Basically, Page 1
    posts to Page 2...and Page 1 contains a variable declared as:

    Dim mLic(50)

    ....which is then populated. When I try:

    Request.Form("m Lic()") or
    Request.Form("m Lic") or
    Request.Form("m Lic(50)")

    I get a type mismatch every time. Is there a better/right way to do this?

    Thanks!
    James


  • Aaron [SQL Server MVP]

    #2
    Re: Request.Form & Arrays

    How are you sending an "array" via post? Get and Post handle strings
    only... you't can pass an array like this and retrieve it via the request
    collection.

    --

    (Reverse address to reply.)




    "James Baker" <cppjames@hotma il.com> wrote in message
    news:ezz2xwJTEH A.544@TK2MSFTNG P11.phx.gbl...[color=blue]
    > I'm trying to use Request.Form to gather information in an array and I[/color]
    keep[color=blue]
    > getting a type mismatch...not sure if it's even possible. Basically, Page[/color]
    1[color=blue]
    > posts to Page 2...and Page 1 contains a variable declared as:
    >
    > Dim mLic(50)
    >
    > ...which is then populated. When I try:
    >
    > Request.Form("m Lic()") or
    > Request.Form("m Lic") or
    > Request.Form("m Lic(50)")
    >
    > I get a type mismatch every time. Is there a better/right way to do this?
    >
    > Thanks!
    > James
    >
    >[/color]


    Comment

    • James Baker

      #3
      Re: Request.Form &amp; Arrays

      Fair enough...(forgi ve me, I'm trying to learn ASP again). Can a Session
      variable handle this? What's the ideal method for "sharing" an array
      between pages?

      James


      "Aaron [SQL Server MVP]" <ten.xoc@dnartr eb.noraa> wrote in message
      news:eStLlzJTEH A.1468@TK2MSFTN GP09.phx.gbl...[color=blue]
      > How are you sending an "array" via post? Get and Post handle strings
      > only... you't can pass an array like this and retrieve it via the request
      > collection.
      >
      > --
      > http://www.aspfaq.com/
      > (Reverse address to reply.)
      >
      >
      >
      >
      > "James Baker" <cppjames@hotma il.com> wrote in message
      > news:ezz2xwJTEH A.544@TK2MSFTNG P11.phx.gbl...[color=green]
      > > I'm trying to use Request.Form to gather information in an array and I[/color]
      > keep[color=green]
      > > getting a type mismatch...not sure if it's even possible. Basically,[/color][/color]
      Page[color=blue]
      > 1[color=green]
      > > posts to Page 2...and Page 1 contains a variable declared as:
      > >
      > > Dim mLic(50)
      > >
      > > ...which is then populated. When I try:
      > >
      > > Request.Form("m Lic()") or
      > > Request.Form("m Lic") or
      > > Request.Form("m Lic(50)")
      > >
      > > I get a type mismatch every time. Is there a better/right way to do[/color][/color]
      this?[color=blue][color=green]
      > >
      > > Thanks!
      > > James
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Aaron [SQL Server MVP]

        #4
        Re: Request.Form &amp; Arrays

        Page 1:

        dim myArray(1)
        myArray(0) = "a"
        myArray(1) = "b"
        session("myArra y") = myArray

        Page 2:

        myArray = session("myArra y")
        response.write myArray(0)

        However, unless this is a complex array, you are likely better off to avoid
        session variable and pass a comma-delimited string around. IMHO.

        --

        (Reverse address to reply.)




        "James Baker" <cppjames@hotma il.com> wrote in message
        news:uSdX52JTEH A.3768@TK2MSFTN GP11.phx.gbl...[color=blue]
        > Fair enough...(forgi ve me, I'm trying to learn ASP again). Can a Session
        > variable handle this? What's the ideal method for "sharing" an array
        > between pages?
        >
        > James
        >
        >
        > "Aaron [SQL Server MVP]" <ten.xoc@dnartr eb.noraa> wrote in message
        > news:eStLlzJTEH A.1468@TK2MSFTN GP09.phx.gbl...[color=green]
        > > How are you sending an "array" via post? Get and Post handle strings
        > > only... you't can pass an array like this and retrieve it via the[/color][/color]
        request[color=blue][color=green]
        > > collection.
        > >
        > > --
        > > http://www.aspfaq.com/
        > > (Reverse address to reply.)
        > >
        > >
        > >
        > >
        > > "James Baker" <cppjames@hotma il.com> wrote in message
        > > news:ezz2xwJTEH A.544@TK2MSFTNG P11.phx.gbl...[color=darkred]
        > > > I'm trying to use Request.Form to gather information in an array and I[/color]
        > > keep[color=darkred]
        > > > getting a type mismatch...not sure if it's even possible. Basically,[/color][/color]
        > Page[color=green]
        > > 1[color=darkred]
        > > > posts to Page 2...and Page 1 contains a variable declared as:
        > > >
        > > > Dim mLic(50)
        > > >
        > > > ...which is then populated. When I try:
        > > >
        > > > Request.Form("m Lic()") or
        > > > Request.Form("m Lic") or
        > > > Request.Form("m Lic(50)")
        > > >
        > > > I get a type mismatch every time. Is there a better/right way to do[/color][/color]
        > this?[color=green][color=darkred]
        > > >
        > > > Thanks!
        > > > James
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Bob Barrows [MVP]

          #5
          Re: Request.Form &amp; Arrays

          James Baker wrote:[color=blue]
          > I'm trying to use Request.Form to gather information in an array and
          > I keep getting a type mismatch...not sure if it's even possible.
          > Basically, Page 1 posts to Page 2...and Page 1 contains a variable
          > declared as:
          >
          > Dim mLic(50)
          >
          > ...which is then populated.[/color]

          Does this occur in client-side or server-side code?

          Bob Barrows
          --
          Microsoft MVP -- ASP/ASP.NET
          Please reply to the newsgroup. The email account listed in my From
          header is my spam trap, so I don't check it very often. You will get a
          quicker response by posting to the newsgroup.


          Comment

          • James Baker

            #6
            Re: Request.Form &amp; Arrays

            Server side...I realized the error of my ways when trying to "POST" the
            array. Now I'm searching for a better approach.


            Comment

            • James Baker

              #7
              Re: Request.Form &amp; Arrays

              Well, I'm toying with the idea of just written out hidden tags/values and
              using request.form that way, as opposed to the array. In order to pass a
              comma delimited string, I'd have to parse/concatenate the entire array,
              right? I'm trying to see the benefit I guess.


              "Aaron [SQL Server MVP]" <ten.xoc@dnartr eb.noraa> wrote in message
              news:uNSxA8JTEH A.3548@TK2MSFTN GP09.phx.gbl...[color=blue]
              > Page 1:
              >
              > dim myArray(1)
              > myArray(0) = "a"
              > myArray(1) = "b"
              > session("myArra y") = myArray
              >
              > Page 2:
              >
              > myArray = session("myArra y")
              > response.write myArray(0)
              >
              > However, unless this is a complex array, you are likely better off to[/color]
              avoid[color=blue]
              > session variable and pass a comma-delimited string around. IMHO.
              >
              > --
              > http://www.aspfaq.com/
              > (Reverse address to reply.)
              >
              >
              >
              >
              > "James Baker" <cppjames@hotma il.com> wrote in message
              > news:uSdX52JTEH A.3768@TK2MSFTN GP11.phx.gbl...[color=green]
              > > Fair enough...(forgi ve me, I'm trying to learn ASP again). Can a[/color][/color]
              Session[color=blue][color=green]
              > > variable handle this? What's the ideal method for "sharing" an array
              > > between pages?
              > >
              > > James
              > >
              > >
              > > "Aaron [SQL Server MVP]" <ten.xoc@dnartr eb.noraa> wrote in message
              > > news:eStLlzJTEH A.1468@TK2MSFTN GP09.phx.gbl...[color=darkred]
              > > > How are you sending an "array" via post? Get and Post handle strings
              > > > only... you't can pass an array like this and retrieve it via the[/color][/color]
              > request[color=green][color=darkred]
              > > > collection.
              > > >
              > > > --
              > > > http://www.aspfaq.com/
              > > > (Reverse address to reply.)
              > > >
              > > >
              > > >
              > > >
              > > > "James Baker" <cppjames@hotma il.com> wrote in message
              > > > news:ezz2xwJTEH A.544@TK2MSFTNG P11.phx.gbl...
              > > > > I'm trying to use Request.Form to gather information in an array and[/color][/color][/color]
              I[color=blue][color=green][color=darkred]
              > > > keep
              > > > > getting a type mismatch...not sure if it's even possible.[/color][/color][/color]
              Basically,[color=blue][color=green]
              > > Page[color=darkred]
              > > > 1
              > > > > posts to Page 2...and Page 1 contains a variable declared as:
              > > > >
              > > > > Dim mLic(50)
              > > > >
              > > > > ...which is then populated. When I try:
              > > > >
              > > > > Request.Form("m Lic()") or
              > > > > Request.Form("m Lic") or
              > > > > Request.Form("m Lic(50)")
              > > > >
              > > > > I get a type mismatch every time. Is there a better/right way to do[/color]
              > > this?[color=darkred]
              > > > >
              > > > > Thanks!
              > > > > James
              > > > >
              > > > >
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • Bob Barrows [MVP]

                #8
                Re: Request.Form &amp; Arrays

                James Baker wrote:[color=blue]
                > Well, I'm toying with the idea of just written out hidden tags/values
                > and using request.form that way, as opposed to the array. In order
                > to pass a comma delimited string, I'd have to parse/concatenate the
                > entire array, right? I'm trying to see the benefit I guess.
                >[/color]

                No. You can use the Join function to return a delimited string from an
                array. You can then response.write the string into a hidden form element.

                Bob Barrows
                --
                Microsoft MVP -- ASP/ASP.NET
                Please reply to the newsgroup. The email account listed in my From
                header is my spam trap, so I don't check it very often. You will get a
                quicker response by posting to the newsgroup.


                Comment

                • James Baker

                  #9
                  Re: Request.Form &amp; Arrays

                  Thanks for your help...I think I'm good to go now. With every passing
                  moment, I appreciate ASP.NET that much more.


                  Comment

                  Working...