Dear all,
Please tell me
after records saved successfully show message 'Saved Success'.
After showing message then wait 5 sec and redirect to another page in asp.net
Please help
Regards
Niranjan Poddar
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manish Kumar ChoudharyPosted Jan 19, 2015, 7:16 AM
You have to implement this logic manually either using JavaScript:
or by adding HTTP header:
or
metatag:see more info.
If it's a desktop application you could use something like timers. And never make main thread (UI Thread) hangs with something like Thread.Sleep.
Niranjan PoddarPosted Jan 19, 2015, 7:11 AM
But this code is not working. its redirect to [redirect page] without showing successfully message.
when i click save button it wait 5 sec then redirect to redirect page.
Suraj SahooPosted Jan 19, 2015, 6:59 AM
for this query which you have stated, you can use ajax call for this.
Explanation:-What you need to do is, make an ajax call and on success show alert message as SUCCESS and then set a small timeout for 5000 ms and after that redirect to another page. The code would like below:-
$.ajax({
url:"/CONTROLLER/ACTION",
type:"GET/POST",
success: function(){
alert("ACTION DONE SUCCESSFULLY");
setTimeout('', 5000);
window.location.href = "/CONTROLLER/ACTION" //redirects to another page wherever you want to.
}
});
I hope this will help you.
Thanks
Manish Kumar ChoudharyPosted Jan 19, 2015, 6:58 AM
Hi Niranjan Poddar,
try to do something like...
Call this function just below the code where you are displaying the save successfully message.
// this is a stub for a asynchronous process
protected void WaitAndRedirect()
{
// This will wait for 5 sec
Thread.Sleep(5000);
// Redirect to another page
Responce.Redirect("~/url ");
}