Yasin Kızıltaş

Yasin Kızıltaş

  • NA
  • 57
  • 4.4k

How to alert message before Response.redirect? or other way

Oct 15 2018 4:41 AM
I have a button on my update page. This button redirects and refreshes the page after sending sms
 
I want that;
 
If the user pushes the button and sends sms 1 time, do not press the same button 2 times unless the page is closed.
 
In fact, I installed the structure, but because the button response is redirect, my page refreshes every time and never falls into the following else. How can I solve this?
 
Response redirect(in controller)
  1. public void SMSGonder(int flowId)    
  2.     {    
  3.         flow flow = db.flow.Find(flowId);    
  4.         string meetingDate = "";    
  5.         foreach (var item in db.sp_get_meeting(flowId))    
  6.         {    
  7.             meetingDate = item.meetingDate.ToString("dd.MM.yyyy HH:mm");    
  8.         }    
  9.         DakikSMSMesajGonder2(flow.flowPhone.ToString(), flow.flowName, meetingDate, null);    
  10.         Response.Redirect("~/flows/Edit?id=" + flowId);    
  11.     }    
href button;
  1. <div class="col-md-4">  
  2. <a class="btn btn-default" id="sms" href="/flows/[email protected]">Sent SMS</a>  
  3. </div>  
and JQuery;
  1. $("#sms").click(function () {  
  2.             var $foo = $(this);  
  3.             if(!$foo.data('clicked'))  
  4.             {  
  5.                 alert("SMS sent successfully!");  
  6.             }  
  7.             else {  
  8.                 alert("You've already sent this sms.");  
  9.             }  
  10.             $foo.data('clicked'true);  
  11.         });  

Answers (7)