Im adding flash message on form submit.
After successful submission im redirecting to route, then displaying the message via base twig template.
But when user goes to another location on the site and then clicks "back" button in the browser message is appearing again.
Is this normal behavior or im doing something wrong?
This is normal behavior since you're returning to a cached version of the previous page, unless it's over SSL or certain headers are set on the server.
What doest you "back" button like like ? Is it a proper link to go the previous page or something in javascript ? (In this case it would be a normal behaviour I assume)
Related
I have a parent page asp.net and in a popup windows I have this:
<body onunload="parent.opener.location.reload()">
<form id="silverlightWindows" runat="server" />
</body>
The problem is that when the popup windows is closed, it always asks this confirmation information with IE and Firefox:
to display the website again, the web browser needs to resend the information you've previously submitted
How can I remove the message warning?
After the user has successfully submitted a form you should redirect the user. This is called the Post/Redirect/Get "pattern".
The message is showing because you are trying to reload the location of the parent window, and that window is currently displaying the result of a post back.
To fix it you will either have to:
Only open the popup after a "normal" non-post back request.
or
Not use use location.reload() but instead use location='(url to load here)'. This could work if the state of the parent window can be restored without the post back data.
or
You could use javascript to cause a postback on the parent window.
to get rid of "Internet Explorer need to resend the information you've previously submitted"
use this script block
> window.parent.opener.document.forms[0].submit() ;
I am redirecting users to a page based on the value I picked from the dropdown.
Response.Redirect("showdetails.aspx?id="+ id);
It is working absolutely fine.
Everytime the user selects an iD it is opening a new tab or page instead of opening in one page.
How can I make sure that it opens in same page instead of opening multiple pages?
Thanks
[Edited due to rethinking]
What you are describing doesn't seem like normal behaviour.
Does the same thing happen on more than one client PC?
If not it's probably a local config issue.
...or...
is the ASP page called via a server-side control with the following attribute:
OnClientClick=”aspnetForm.target =’_blank’
If so, that's why.
I am working in ASP.NET (framework 2.0) with Master Pages.
I have a page that requires registration and then the user gets kicked back to the referring page.
I need to figure out how to provide a success lightbox that appears over the referring page, not the registration page (the event is fired on form submit).
I have the inline stuff in the master page and the scripts and everything fires just fine but the form is refreshed with the new (referring) page and the DIV gets hidden again.
Is sessions the only way to go here? Is there a way of having one lightbox appearing from the master page regardless of what the sub-pages are doing?
Thanks.
There should be a successful registration event. Can you emit some javascript in that scenario that would cause a redirection to the referring page. You could pass a parameter which would indicate that a light box should show up. I don't think you can redirect directly from successful registration because I am guessing that some cookie would need to be set- which the framework should handle. I might be off, but that is where I would start. I would try and avoid Session if possible.
An outside vendor did some html work for us, and I'm filling in the actual functionality. I have an issue that I need help with.
He created a simple html page that is opened as a modal pop-up. It contains a form with a few input fields and a submit button. On submitting, an email should be sent using info from the input fields.
I turned his simple html page into a simple aspx page, added runat=server to the form, and added the c# code inside script tags to create and send the email.
It technically works but has a big issue. After the information is submitted and the email is sent, the page (which is supposed to just be a modal pop-up type thing) gets reloaded, but it is now no longer a pop-up. It's reloaded as a standalone page.
So I'm trying to find out if there is a way to get the form to just execute those few lines of c# code on submission without reloading the form. I'm somewhat aware of cgi scripts, but from what I've read, that can be buggy with IIS and all. Plus I'd like to think I could get these few lines of code to run without creating a separate executable.
Any help is greatly appreciated.
If you don't want the page to reload after submission, you will need to use AJAX. that is alot more complicated. you would still need the submit.aspx, you cannot send email with javascript.
Code a redirect after the form submission, so instead of getting the same form back in the main document/page, you could get something like a blank page saying "Thanks for your submission!" or something of that nature.
Might be more simple to redirect the user to a result page using Respone.Redirect that displays some sort of "Your email has been sent" message, or even just redirect back to the base page.
I have an asp.net application that runs exclusively on IE7 (internal web site).
When a user needs to enter data, I pop up a child window with a form. When the form closes, it calls javascript:window.opener.location.reload(true) so that the new data will display on the main page.
The problem is that the browser complains that it must repost the page. Is there any way to turn this feature off?
No, but there is a solution. Its generally considered good design to use a 302 redirect immediately after someone posts data to a page. This prevents that popup from ever occuring. Allow me to elaborate.
1) The user fills in a form and submits data via POST.
2) The backend receives the data and acts upon it.
3) Instead of returning the content to the user, the backend issues a 302 redirect as soon as its done processing the page (possibly redirecting the user back to the exact same url, if need be)
4) The page that the user will see is the page you told their browser to redirect to. They will load up the redirected page with a standard GET request. If they try to refresh the page, it will not repost the data. Problem solved.
This is a problem with the usual "postback" way of ASP.NET. If you need to reload a page without this warning, this page must come from a GET, not a POST. You could do a Response.Redirect("...") yourself. But this will destroy the use of viewstate.
asp.net mvc fixes this issue, not an ie7 only problem but a security feature of most browsers. No fix that I know of except you could just update the content in the main form with js rather than reloading the whole page
It's because the page in window.opener comes from a POST Request
Maybe you can use
javascript:window.opener.location = window.opener.location; to do just a GET request if the data can be fetched without a POST.
I do not believe that there is a way to do that. Instead, why not direct the parent window to a page without a reload.
javascript:window.opener.location='your url'
AFAIK, not via your scripts.
You might try:
window.opener.location = '#';
It should circumvent the browser reposting. And, you can adjust the hash name as needed.
If you move from page1 to page2, and want to disable the browser from going back to page 1,then add the following at the top of page1.
<script>
if(window.history.forward(1) != null)
window.history.forward(1);
</script>