Passing variables to and fro?

Results 1 to 2 of 2

Thread: Passing variables to and fro?

  1. #1
    Join Date
    Dec 1969

    Default Passing variables to and fro?

    I created an online form for users to register all info about a given equipment. A first validation is made in the OnSubmit event to make sure all required fields are filled, and a second is made in the next page prior to adding that record to the database.<BR>So my problem is this: i pass through a POST method all the info from page 1 to page 2, but if there is a field specific error detected by the validation on page 2 i need to go back to page 1 with all the fields still there a way to use the same POST object, or reuse it in some way? Or is there another way of going back to page 1 with all the fields still there and notify the user of the error that got detected?<BR>BTW we use ASP 2.5, so I don&#039;t have access to the 3.0 specific objects and methods...

  2. #2
    Join Date
    Dec 1969

    Default Don't do it that way...

    POST to the *SAME PAGE*.<BR><BR>Check for all the fields being right, and if they are wrong (or non-existent, as they will be first time on the page) then show the form with the values from the last time in place:<BR><BR>&#060;INPUT Type=Text Name="Foo" Value="&#060;%= Request("Foo") %&#062;" &#062;<BR><BR>If all values from the POST are valid, then do NOT show the form and instead process them (e.g., add the record to the DB) and *THEN* Response.Redirect to the next logical page.<BR><BR>This is *TONS* more efficient than any of the other methods. (Typically, you&#039;d copy all the form field values to session variable, redirect back to the &#060;FORM&#062; page, and then fill in the form fields from the session variables. Which works, but involves two extra steps.)<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts