PopUp Message while navigating from one aspx page to another - c#

Can anybody help me out with the popup message related concept in ASP.NET.
I have been working in ASP.NET MVC, and I am getting no popup message with the below code while navigating from one aspx page to another.
Response.Write("<script>alert('Data is Updated')</script>");
Response.Redirect("WebForm2.aspx");

The pop-up is not occurring because of the redirect. Both the alert and the redirect are being done in server-side code. There is no way to wait for user interaction on the client side because the server-side code has already executed by the time the user sees it.
You could move the alert and redirect to client side JavaScript. The redirect would not fire until the alert is closed.
alert("Successful");
window.location = "WebForm2.aspx";
Or, you could send the message as an url parameter in your server-side redirect, and handle the message display on WebForm2.aspx.
Response.Redirect("WebForm2.aspx?status=successful");

Related

Getting 302 response code in widget ajax call

I am working on a MVC application in which when have an option to request password reset email. When we got the email with the link, that link will redirect to the welcome page where we will enter Password and Confirm password and then we will click continue. Once all the validations of Welcome page passed, the user will be redirected to Dashboard page where we are loading few widgets through ajax calls. In one of our production environment these ajax calls are giving 302 http code instead of 200. Due to this behavior the widgets are loading either welcome page or login page as their content instead of original content. From the code base, no where we are redirecting to Welcome page or login page from any of the widget ajax calls. As this is happening in only production environment but not in local, it became hard to debug.
Can anyone please help guide me on how to figure out the cause of redirection.
Thanks....

Asp.net Redirect after a Javascript alert breaks it

In code behind I'm currently using an alert after submitting a form.
It alerts the user with success message then redirects him to "OtherPage.aspx" using Javascript
ClientScript.RegisterStartupScript(Me.[GetType](), "Success", "<script type='text/javascript'>alert('The windows has been successfully updated ');window.location='OtherPage.aspx';</script>'")
I would like to add a code under It to redirect the user in case javascript is off
But the problem is if I write Server.Transfer or Response.Redirect the alert will no longer show up

How to stop form resubmission on browser back button being pressed by the client

How can I stop my form from being resubmitted in asp.net when the client clicks on the browser back button.
You can prevent the resubmission of a page redirecting the POST action to a GET one.
Keep a look in PRG Pattern and how implement it in C# if using MVC or try try this approach

PageClose Event in asp.net

when user close the web site that time i need to call some function here, what was the event for user close the page or browser in asp.net(C#).
You cannot do this with asp.net. The server does not know when the user closes the window. However you can use javascript, and attach an beforeunload event to the body tag.
window.onbeforeunload = function (e) {
//javascript code here
}
Here is a good SO thread on how this can be achieved.
There is no event in asp.net that could catch the event of user closing the window, because that happens on client-side. Your C# code runs on the server without any knowledge of the client's software.
There are some mechanisms using javascript and sending some data using ajax, but no one should rely on that.

To display the webpage again, the web browser needs to resend the information

When I User Window.Location.reload(true) I am getting the popup message for each and every request. Could any body suggest me how to resolve this Issue?
To display the webpage again, the web browser needs to resend the
information
This is the result of sending data via an HTTP POST (which is most commonly done by submitting a form). You will either need to stop using a POST or perform an intermediary redirect to remove this message.

Categories

Resources