Jquery masked input control with knockout JS

Below is the sample code for phone and date mask with knockout js and jquery masked input


 <script src="http://knockoutjs.com/downloads/knockout-3.4.0.js" type="text/jscript"></script>  
 <script src="https://code.jquery.com/jquery-2.2.2.js" type="text/jscript"></script>  
 <script src="https://rawgit.com/digitalBush/jquery.maskedinput/1.4.1/dist/jquery.maskedinput.js" type="text/jscript"></script>  
 PhoneNumber :  
 <input type="text" id="txtPhoneNumber" data-bind="MaskedInput: WorkPhone, mask: '(999) 999-9999'" />  
 </br>  
 </br>  
 Date :  
 <input type="text" id="txtDate" data-bind="MaskedInput: Date, mask: '99/99/9999'" />  
 <script>  
   var ViewModel = function () {  
     var self = this;  
     self.WorkPhone = ko.observable('');  
     self.Date = ko.observable('');  
     ko.bindingHandlers.MaskedInput = {  
       init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {  
         ko.bindingHandlers.value.init(element, valueAccessor, allBindings, viewModel, bindingContext);  
       },  
       update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {  
         ko.bindingHandlers.value.update(element, valueAccessor, allBindings, viewModel, bindingContext);  
         $(element).mask(allBindings.get('mask'));  
         valueAccessor()($(element).val());  
       }  
     };  
     //uncomment the following line to enable ko.validation for the control, otherwise validation for the control won't work.  
     //ko.validation.makeBindingHandlerValidatable('MaskedInput');  
   }  
   ko.applyBindings(new ViewModel());  
 </script>  

What is the difference between char, nchar, varchar, and nvarchar in SQL Server?

nchar:

 1) support unicode characters
 2) fixed length variable
 3) Maximum length of 4,000 characters.
 3) it will reserve  storage space for number of size you specify.

e.g: nchar(10) if you store only 3   characters and it will reserve space for 10 characters and remaining 7 character space  will be waste.

char:

 1) does not support unicode character.
 2) fixed length variable 
 3) Maximum length of 8,000 characters.
 4) it will reserve  storage space for number of size you specify.

 e.g: nchar(10) if you store only 3   characters and it will reserve space for 10 characters and remaining 7 character space  will be waste.


varchar:

 1) does not support unicode character.
 2) variable length variable
 3) varchar(n) - Maximum 8,000 characters and varchar(max) - Maximum 1,073,741,824 characters
 4) it will reserve storage space for the data you store.

e.g: nvarchar(50) if you store only 25   characters and it will reserve space only for 25 characters and remaining 25 character space  will not allocate  in memory.

nvarchar:

 1) support unicode characters
 2) variable length variable
 3) nvarchar(n) - Maximum 4,000 characters and nvarchar(max) - 536,870,912 characters
 4) it will reserve storage space for the data you store.

e.g: nvarchar(50) if you store only 25   characters and it will reserve space only for 25 characters and remaining 25 character space  will not allocate  in memory.

Sort Alphanumeric Grid View Values

Sort Alphanumeric Grid View Values in Asp.net

In Asp.net gridview there is no option to sort the alpha numeric values by default. So i Google some sorting Algorithm and finally got the  good Article from -  http://www.davekoelle.com and i mixed up the algorithm with the gridview it works very well.

download the working sample example here:


C# 4.0 language Spefication doc

Download  C# 4.0 language documents from Microsoft

Disable Double Click Asp.net Button

How to Prevent Double click in Asp.net

The following snippets will prevent you from the Double click 


 Just use the below line code under page_load event:

cmdSubmit.Attributes.Add("onclick", "this.disabled=true;" + ClientScript.GetPostBackEventReference(cmdSubmit,"").ToString());

note:-  cmdSubmit should be Asp.net Button Name

How to Read all blob list from the Windows Azure Storage Containers

Read all Blob List Names from the Windows Azure Containers


The Following snippets is used to read all the Blob list details from the azure containers
and also we can avoid the transport connection error while reading the huge blob list.
by the paging segment concept can able to read large no of blob list...
       
 
              ///////// Getting Blobs List if it's below than 5000 ///////////  
 
             TextWriter  tw = new  StreamWriter ("d:/blob_thumblist.txt" );            
             int  pagingCount = 1000;
             CloudStorageAccount  storageAccount = CloudStorageAccount .Parse(ConfigurationSettings .AppSettings["CloudStorage" ].ToString());
             CloudBlobClient  blobClient = storageAccount.CreateCloudBlobClient();
             //Get a reference to the container. 
             CloudBlobContainer  container = blobClient.GetContainerReference("ContainerName" );
  
             ///////// Getting Blobs if's below than 5000 ///////////  
 
             //Return blobs using a flat listing. 
             BlobRequestOptions  options = new  BlobRequestOptions ();
             options.UseFlatBlobListing = true ;
 
             ////This first operation will return up to 5000 blobs. 
             ResultSegment <IListBlobItem > resultSegment = container.ListBlobsSegmented(options);
             foreach  (var  blobItem in  resultSegment.Results)
             { 
                 //writing the blob name into the text file  
                 tw.WriteLine(blobItem.Uri.Segments[2]);
             }
             //close the stream 
             tw.Close();
 
   
           ///////// Getting Blobs List if it's more  than 5000 /////////// 
 
             TextWriter  tw = new  StreamWriter ("d:/blob_thumblist.txt" ); 
             int  pagingCount = 1000;
             CloudStorageAccount  storageAccount = CloudStorageAccount .Parse(ConfigurationSettings .AppSettings["CloudStorage" ].ToString());
             CloudBlobClient  blobClient = storageAccount.CreateCloudBlobClient();
             //Get a reference to the container. 
             CloudBlobContainer  container = blobClient.GetContainerReference("ContainerName" );
             ///////// Getting Blobs if's more  than 5000 /////////// 
 
             ResultContinuation  continuationToken = resultSegment.ContinuationToken;
 
             //Check whether there are more results and list them in pages of 1000. 
             while  (continuationToken != null )
             {
                 resultSegment = container.ListBlobsSegmented(pagingCount, continuationToken, options);
                 foreach  (var  blobItem in  resultSegment.Results)
                 {
                     //writing the blob name into the text file  
                     Console .WriteLine(blobItem.Uri.Segments[2]);                           
                 }
         
                 //getting blob list count per Paging 
                 Console .WriteLine(resultSegment.Results.Count());
                 //Console.ReadLine(); 
                 continuationToken = resultSegment.ContinuationToken;
                 //calling next set of blob list 
                 resultSegment.GetNext();
        
             }
 
              //close the stream 
             tw.Close();
 

How to Check Azure Blob List Exist or Not

Check Blob List Exist or Not

use the following snippet to check whether the blob is Exist or not
   
public  static  bool  Exists(this  CloudBlob  blob)
         {
             try 
             {
                 blob.FetchAttributes();
                 return  true ;
             }
             catch  (StorageClientException  e)
             {
                 if  (e.ErrorCode == StorageErrorCode .ResourceNotFound)
                 {
                     return  false ;
                 }
                 else 
                 {
                     throw ;
                 }
             }
         }