ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Execute code on Confirmation Box OK Button Click using JavaScript in ASP.Net MVC<p>Hi&nbsp;chetan,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { return View(); } [HttpPost] public ActionResult CheckEmail(string checkemails) { //calling Stored Procedure if (!string.IsNullOrWhiteSpace(checkemails) || checkemails == &#34;true&#34; || checkemails == &#34;false&#34;) { var checkemails1 = new SqlParameter(&#34;checkemails&#34;, checkemails); db.Database.ExecuteSqlCommand(&#34;EXEC Sp_Email_on_off @checkemails&#34;, checkemails1); } return new JsonResult { }; } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;script type=&#34;text/javascript&#34; src=&#34;https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(document).ready(function () { $(&#39;[id*=btnturnemailonoff]&#39;).on(&#39;click&#39;, function () { var checked = !$(this).data(&#39;checked&#39;); var message = checked ? &#39;Turn Email Off&#39; : &#39;Turn Email ON&#39;; if (confirm(&#34;Do you want to &#34; + message + &#34;? &#34;)) { $(&#34;#Chkemailonoff&#34;).prop(&#39;checked&#39;, checked); $(this).val(checked ? &#39;Turn Email Off&#39; : &#39;Turn Email ON&#39;); $(this).data(&#39;checked&#39;, checked); $.ajax({ url: &#34;Home/CheckEmail&#34;, type: &#34;POST&#34;, data: { checkemails: checked }, dataType: &#34;json&#34;, success: function () { alert(&#34;ajax request to server succeed&#34;); } }); } }); }); &lt;/script&gt; &lt;input type=&#34;button&#34; value=&#34;Turn Email ON&#34; id=&#34;btnturnemailonoff&#34; /&gt; &lt;input type=&#34;checkbox&#34; id=&#34;Chkemailonoff&#34; /&gt;</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/FDa0E6Q.gif" alt="" width="288" height="191" /></span></strong></p>https://www.aspforums.net:443/Threads/152317/Execute-code-on-Confirmation-Box-OK-Button-Click-using-JavaScript-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/152317/Execute-code-on-Confirmation-Box-OK-Button-Click-using-JavaScript-in-ASPNet-MVC/Mon, 08 Jul 2019 04:37:46 GMT