Tuesday, April 19, 2016

[Solved] Ajax async postback end does not work Script Error : Uncaught Sys.ScriptLoadFailedException: Sys.ScriptLoadFailedException: The script failed to load. Check for: Inaccessible path. Script errors. (IE) Enable 'Display a notification about every script error' under advanced settings. Missing call to Sys.Application.notifyScriptLoaded().

Solution For ajax async postback end does not work


 <script type="text/javascript">  
      function pageLoad(sender, args) {  
        //$(document).ready(function () {  
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginReq);  
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endReq);  
        Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit  
        if (navigator.userAgent.indexOf('WebKit/') > -1) {  
          Sys.Browser.agent = Sys.Browser.WebKit;  
          Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);  
          Sys.Browser.name = 'WebKit';  
        }  
        var xPos, yPos;  
        function beginReq(sender, args) {  
          //  $find(ModalPopup).show();  
        }  
        function endReq(sender, args) {  
          //  $find(ModalPopup).hide();  
        }  
        //});  
      }  
 </script>  

Use this script inside the page. :)

Wednesday, December 9, 2015

Send SMS From SQL Server Using SMS API


                Declare @MobileNo varchar(12)='Mobile Number', @smstext as varchar(300)='Message'  
                Declare @iReq int,@hr int   
                Declare @sUrl as varchar(500)   
                DECLARE @errorSource VARCHAR(8000)  
                DECLARE @errorDescription VARCHAR(8000)   
                EXEC @hr = sp_OACreate 'Microsoft.XMLHTTP', @iReq OUT                  
                if @hr <> 0   
                  Raiserror('sp_OACreate Microsoft.XMLHTTP FAILED!', 16, 1)   
                set @sUrl='http://sapteleservices.com/SMS_API/sendsms.php?username=YourUserName&password=YourPassword&mobile=#MobNo#&sendername=YourCode&message=#Msg#&routetype=1'  
                set @sUrl=REPLACE(@sUrl,'#MobNo#',@MobileNo)   
                set @sUrl=REPLACE(@sUrl,'#Msg#',@smstext)   
                EXEC @hr = sp_OAMethod @iReq, 'Open', NULL, 'GET', @sUrl, true   
                if @hr <> 0   
                     Raiserror('sp_OAMethod Open FAILED!', 16, 1)   
                EXEC @hr = sp_OAMethod @iReq, 'send'   
                if @hr <> 0   
                  Begin   
                    EXEC sp_OAGetErrorInfo @iReq, @errorSource OUTPUT, @errorDescription OUTPUT  
                    Raiserror('sp_OAMethod Send FAILED!', 16, 1)   
                  end   
                else   
                Begin  
                  EXEC @hr = sp_OAGetProperty @iReq,'responseText'  
                  /*SMS LOG IF ANY*/  
                end  

*IF THERE ANY ERROR PLEASE EXECUTE THIS FIRST THEN TRY AGAIN

 exec sp_configure 'show advanced options', 1  
 go  
 reconfigure  
 go  
 exec sp_configure 'Ole Automation Procedures', 1 -- Enable  
 -- exec sp_configure 'Ole Automation Procedures', 0 -- Disable  
 go  
 reconfigure  
 go  
 exec sp_configure 'show advanced options', 0  
 go  
 reconfigure  
 go  


Wednesday, October 7, 2015

How To do Case Sensitive String Match in SQL Server

Using:
 COLLATE SQL_Latin1_General_CP1_CS_AS  

Example:
 select * from tblUser where userpwd='aBcD.123' COLLATE SQL_Latin1_General_CP1_CS_AS ; 

Sunday, June 28, 2015

C# Function to Convert Number to Words


 public static string NumbersToWords(int inputNumber)  
   {  
     int inputNo = inputNumber;  
     if (inputNo == 0)  
       return "Zero";  
     int[] numbers = new int[4];  
     int first = 0;  
     int u, h, t;  
     System.Text.StringBuilder sb = new System.Text.StringBuilder();  
     if (inputNo < 0)  
     {  
       sb.Append("Minus ");  
       inputNo = -inputNo;  
     }  
     string[] words0 = {"" ,"One ", "Two ", "Three ", "Four ",  
       "Five " ,"Six ", "Seven ", "Eight ", "Nine "};  
     string[] words1 = {"Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ",  
       "Fifteen ","Sixteen ","Seventeen ","Eighteen ", "Nineteen "};  
     string[] words2 = {"Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ",  
       "Seventy ","Eighty ", "Ninety "};  
     string[] words3 = { "Thousand ", "Lakh ", "Crore " };  
     numbers[0] = inputNo % 1000; // units  
     numbers[1] = inputNo / 1000;  
     numbers[2] = inputNo / 100000;  
     numbers[1] = numbers[1] - 100 * numbers[2]; // thousands  
     numbers[3] = inputNo / 10000000; // crores  
     numbers[2] = numbers[2] - 100 * numbers[3]; // lakhs  
     for (int i = 3; i > 0; i--)  
     {  
       if (numbers[i] != 0)  
       {  
         first = i;  
         break;  
       }  
     }  
     for (int i = first; i >= 0; i--)  
     {  
       if (numbers[i] == 0) continue;  
       u = numbers[i] % 10; // ones  
       t = numbers[i] / 10;  
       h = numbers[i] / 100; // hundreds  
       t = t - 10 * h; // tens  
       if (h > 0) sb.Append(words0[h] + "Hundred ");  
       if (u > 0 || t > 0)  
       {  
         if (h > 0 || i == 0) sb.Append("and ");  
         if (t == 0)  
           sb.Append(words0[u]);  
         else if (t == 1)  
           sb.Append(words1[u]);  
         else  
           sb.Append(words2[t - 2] + words0[u]);  
       }  
       if (i != 0) sb.Append(words3[i - 1]);  
     }  
     return sb.ToString().TrimEnd();  
   }