Form Repopulation on Redirect using ASP - forms

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?

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.

Related

Symfony form validation on redirected page

Is it possible to display the form error on a redirected page instead of a rendered page?
I have 2 forms on 1 page each submitting to their own actions. If form 1 is not valid it will skip if($form->isValid()) and go straight to render
which will then display the form errors. The 'render` for this actions only displays form 1).
The issue with this is I would like it to redirect back to the original page where I have both of the forms but still display the form errors.
I don't know any easy way to do this, so I give you an idea how this could be done the "hard" way:
Serialize the validated form using JMSSerializerBundle
Set the serialized form as flashbag message
Redirect
Check for the form in the flashbag, unserialize, show the errors of both.

Wicket: Loosing form input on page re-render

I have pages with forms. Everything is working fine. Except, that there is a link (language selecter) on the pages. The requirement is, that when the user has already input in the form fields and than (without submitting the form) is clicking the link, all input should be retained.
If the link would be part of the form, this could easily archived via a SubmitLink and submitLink.setDefaultFormProcessing(false);
Unfortunately, this link has no knowledge of the form(s) on this page.
Any pointers if this is solvable? Of course, validation should not be triggered.
client-side JavaScript solution
wrap complete page content in a form
(yes, Wicket allows nesting of forms) and use an SubmitLink with
defaultFormProcessing=false
add an AjaxFormComponentUpdatingBehavior
to all your form fields, so the input is always sent to the server

i am not able to keep my wicket form fields blank after browser refresh once they are submitted on the page. my fields are present in a group box

I am not able to keep my wicket form fields blank after browser refresh once they are submitted on the page; my fields are present in a group box.
I have a wicket form with a group box which is having a date picker and text field. If I am entering data and submitting it gives success response. On browser refresh, I want those fields to become empty but they don't.
I tried setting every field to blank after success response as fieldName.setModelValue(new String[]{" "});.
I need this to be done at browser refresh handling without setting it everywhere.
You have (at least) these three options:
1) on success redirect to a fresh instance of the current page, i.e. setResponsePage(getPage().getClass())
2) stay on the current page, but set an "empty" model to the Form. By "empty" I mean whatever "empty" means in your context. Use #setModel() on the form or on the form component. Do not use #setModelValue().
3) Use a stateless page (with StatelessForm) if this is possible

Angularjs default action form submit

My angular application needs to submit a form to a vendor. They then redirect the user to a page that I specified earlier in the process.
So I want standard, non-angular html form submit behaviour.
The documentation (details below) makes it sound like all I need to do is add an action attribute to my form element. I have tried this and it does not work.
Has anyone used this functionality in angular? Is there another step that I am missing?
The relevant section of the documentation at https://docs.angularjs.org/api/ng/directive/form is:
Submitting a form and preventing the default action
Since the role of forms in client-side Angular applications is different than in classical roundtrip apps, it is desirable for the browser not to translate the form submission into a full page reload that sends the data to the server. Instead some javascript logic should be triggered to handle the form submission in an application-specific way.
For this reason, Angular prevents the default action (form submission to the server) unless the element has an action attribute specified.
Angular does that. When you provide an action on the form, it should do exactly what you're trying to do (do a javascript thing, then submit the form).
Here is a plunk
In the plunk, you can see the $scope.submitted say 'submitted' just before the form submission kicks the page over to the submitted.html

Stop Form Submission on Page refresh?

I have a simple asp form which is used to insert data into the database.It's working fine on click of submit button.But it again submits itself on press of refresh.How t stop the form from doing so?
The following might work:
Store a unique form data value (timestamp?) in a cookie or session variable and check it to prevent re-processing ..
Redirect your page to itself with a GET (see also snipplr.com/view/35515/) and check (POST versus GET) on processing the page..