Skip to main content

Posts

Showing posts from April, 2017

Set unique background color to each div in page using jQuery.

Here I will explain hoe to set unique background-color in div using jQuery. <html> <head> <title></title> <meta charset="utf-8" /> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> <style type="text/css">     .bg-red {         background-color: red;     }     .bg-pink {         background-color: pink;     }     .bg-purple {         background-color: purple;     }     .bg-green {         background-color: green;     }     .bg-yellow {         background-color: yellow;     }     .bg-lime {         background-color: lime;     }     .bg-blue {         background-color: blue;     }     div.activity_type {         width: 100px;         height: 100px;         float: left;     } </style> <script type="text/javascript">     $(document).ready(function () {         var myColors = ['bg-red', 'bg-pink', 'bg-purple', 'bg-yellow', 'bg-gree

Generating serial numbers and keys in Asp.net(C#).

here we are using GUID for generate serial numbers and GUID is always unique. Example format: XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX. Guid SerialKeyGuid = Guid.NewGuid(); string AccessKey = SerialKeyGuid.ToString("N"); string AccessKeyLength = AccessKey.Substring(0, 28).ToUpper(); char[] serialArray = AccessKeyLength.ToCharArray(); string SerialNumber = ""; int P = 0; for (int B = 0; B < 28; B++) {                 for (P = B; P < 4 + B; P++)                 {                     SerialNumber += serialArray[P];                 }                 if (P == 28)                 {                     break;                 }                 else                 {                      B = (P) - 1;                      SerialNumber += "-";                 } }

Store and Retrive Connection string from INI file or Configuration file.

Here I will explain how to store or retrive connection string in INI file or Configuration file. Add this namespace. using System.Runtime.InteropServices; using System.Text; Add  this code on your page. [DllImport("kernel32", CharSet = CharSet.Unicode)] static extern int GetPrivateProfileString(string Section, string Key, string Default, StringBuilder RetVal, int Size, string FilePath); [DllImport("kernel32")] static extern long WritePrivateProfileString(string section, string key, string val, string filePath); public void Write(string section, string key, string value) {      WritePrivateProfileString(section, key, value, System.Web.HttpRuntime.BinDirectory + "Config.ini"); } For Write in .ini file. Write("config", "IP", IP); Write("config", "DB", DB); Write("config", "U", Username); Write("config", "P", Password); Sample Config.ini File [config] IP=jGBat