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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 19, 2015, 1:58 AM EST
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 ");
}
Suraj SahooRank #382 · 6.6K reputationPosted Jan 19, 2015, 1:59 AM EST
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
Niranjan PoddarRank #2,683 · 519 reputationPosted Jan 19, 2015, 2:11 AM EST
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.
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 19, 2015, 2:16 AM EST
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.