ajax call using jquery in asp.net

Event:

 <a class="btnTwo btnTwoOrange btnSelectSend" href="JavaScript:" id="btnSelectSend" onclick="SendEmail();">Gönder</a>  

Javascript:

  <script type="text/javascript">  
       function SendEmail() {  
         var bookId = document.getElementById("BookID").value;  
         var name = document.getElementById("sendername").value;  
         var email = document.getElementById("senderEmail").value;  
         $.ajax({  
           type: "POST",  
           url: "Forbes.aspx/SendEmail",  
           data: "{ bookId: '" + bookId + "',name: '" + name + "',email: '" + email + "'}",  
           contentType: "application/json; charset=utf-8",  
           dataType: "json",  
           async: "true",  
           cache: "false",  
           success: function (msg) {  
            // do something            
           },  
           Error: function (x, e) {  
             // On Error  
           }  
         });  
       }  
     </script>  


In to CS file:


   [WebMethod]  
     public static void SendEmail(string bookId, string name, string email)  
     {  
       try  
       {  
         MemberService.SendForbesEmail(bookId, name, email, db, m_Member);  
       }  
       catch (Exception ex)  
       {  
         throw;  
       }  
     }   


Hope it will help you.




Popular posts from this blog

WPF Crystal Report Viewer Using SAP

mvc razor textboxfor change event change another textboxfor value

ASP.NET MVC razor SAP Crystal report