Sunday, April 19, 2015

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.




Session value set and get in to java script ASP.NET

Set session value in to your java script any event:

 <%Session["aux1_7"]="7";%>;  


Get value in to your java script any event:


  var someSession = '<%= Session["aux1_7"] %>';  
         if (someSession) {  
           // Do something  
         }  

Tuesday, April 7, 2015

kendo ui grid hide toolbar button


If you want to hide or show any toolbar button (Add, Edit & delete) of kendo UI grid you can use this script .


  $(document).ready(function () {  
                // Your Grid   
               // menu enable & disable  
               var MenuEdit = '@ViewData["MenuEdit"].ToString()';  
               alert(MenuEdit);  
               if (MenuEdit == 0) {  
                 $(".k-grid-add", "#DefaultGrid").hide();  
                 $(".k-grid-edit", "#DefaultGrid").hide();  
                 $(".k-grid-delete", "#DefaultGrid").hide();  
               }  
               else {  
                 $(".k-grid-add", "#DefaultGrid").show();  
                 $(".k-grid-edit", "#DefaultGrid").show();  
                 $(".k-grid-delete", "#DefaultGrid").show();  
               }  
             });  

Note: Define the script after your Kendo UI Grid.

SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...