views:

73

answers:

1

I'm currently working on an application that uses ASP, and I am currently having difficulty repopulating the fields of a form after redirecting back to that form.

Basically, I have a form where a user can input data into it (Say, an admin creating a new user within the system). Upon clicking the "Submit" button on the form, it goes to a processing page (say, userproc.asp) where it does input validation and adds the user to the database.

My issue is when the input validation fails, the application needs to return the user to the Form, report the issue, and keep the form populated as it was before clicking on submit.

This is where my problem lies, as I cannot find a good way to get a form to repopulate properly upon redirecting back to it using ASP. We do not want to use Javascript either.

Any thoughts/suggestions?

+1  A: 

Make the Action for the Form point to itself instead of to a different "processing" page.

Remove the "processing" code that performs the validation and "user creation" for the "processing" page and place it in a Class defined in a new ASP page. This page is code only (just contains this class).

Include the new Class asp file in the orginal form page. On receiving a post instantiate the class and call an "Process" method where all your original code will work.

Have the method return some indication of success. If it has succeeded now you could either redirect to a "success page" or simply include the success markup in the form page. If the processing is failed you return your original form with the addition that you can set the values for all the fields to the ones received.

AnthonyWJones