Skip to main content

Posts

Showing posts from November, 2012

Popup form on Screen Center Javascript

Popup Form on Center  to popup the form on Screen Center use the below Script Example : <script language="javascript"> var popupWindow = null; function centeredPopup(url,winName,w,h,scroll){ LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable' popupWindow = window.open(url,winName,settings) } </script> <p><a href="http://www.quackit.com/common/link_builder.cfm" onclick="centeredPopup(this.href,'myWindow','500','300','yes');return false">Centered Popup</a></p>

Using RNGCryptoServiceProvider and Character Masking

Uniquekey Generate Method Code : using System.Security.Cryptography; import the above class for using the code private string GetUniqueKey()   {   int maxSize  = 8 ;   int minSize = 5 ;   char[] chars = new char[62];   string a;   a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";   chars = a.ToCharArray();   int size  = maxSize ;   byte[] data = new byte[1];   RNGCryptoServiceProvider  crypto = new RNGCryptoServiceProvider();   crypto.GetNonZeroBytes(data) ;   size =  maxSize ;   data = new byte[size];   crypto.GetNonZeroBytes(data);   StringBuilder result = new StringBuilder(size) ;   foreach(byte b in data ) { result.Append(chars[b % (chars.Length - 1)]); }    return result.ToString();   } Generation Method Time Taken Number of Generated Keys Number of Duplicate Keys All Fixed Length Keys Using DateTime and HashCode 01.56 sec  10,00,000

Get Query String Values by Javascript

Get Query String Values by Javascript Script Function function GET () { var data = []; for ( x = 0 ; x < arguments . length ; ++ x ) data . push ( location . href . match ( new RegExp ( "/\?" . concat ( arguments [ x ], "=" , "([^\n&]*)" )))[ 1 ]) return data ; } Example : data = GET ( "id" , "name" , "foo" ); query string : ? id = 3 & name = jet & foo = b returns : data [ 0 ] // 13 data [ 1 ] // jet data [ 2 ] // b or alert ( GET ( "id" )[ 0 ]) // return 3