5/08/2012

Jquery get ID in ASP.NET

 

$('[id$=timePicker]').timepicker();

Save And Share :

Show Your IP by JSON JQuery

Function javascript:

   1:  function ShowMyIP() {
   2:      var url = "http://jsonip.appspot.com?callback=?";     
   3:      $.getJSON(url, function(data) {
   4:          //show client IP from url
   5:          $('#ip_location').html("Your Ip Location:" + data.ip);         
   6:      });
   7:  }

 

Html:

<div id=”ip_location”></div>

JQuery call function

   1:  $(document).ready(function() {    
   2:      ShowMyIP();   
   3:  });

Save And Share :

Get Location by using Jquery

   1:  jQuery.getScript('http://www.geoplugin.net/javascript.gp', function()
   2:  {
   3:      $('#getScript-results').html("Your location is: " + geoplugin_countryName() + ",
   4:      " + geoplugin_region() + ", " + geoplugin_city());
   5:  });

 

Data Json result

 

function geoplugin_request() { return '117.5.192.65';} 
function geoplugin_status() { return '200';} 
function geoplugin_city() { return 'Hanoi';} 
function geoplugin_region() { return 'Ha Nội';} 
function geoplugin_regionCode() { return '44';} 
function geoplugin_regionName() { return 'Ha Nội';} 
function geoplugin_areaCode() { return '0';} 
function geoplugin_dmaCode() { return '0';} 
function geoplugin_countryCode() { return 'VN';} 
function geoplugin_countryName() { return 'Vietnam';} 
function geoplugin_continentCode() { return 'AS';} 
function geoplugin_latitude() { return '21.033300';} 
function geoplugin_longitude() { return '105.849998';} 
function geoplugin_currencyCode() { return 'VND';} 
function geoplugin_currencySymbol() { return '&#8363;';} 
function geoplugin_currencyConverter(amt, symbol) { 
	if (!amt) { return false; } 
	var converted = amt * 20810; 
	if (converted <0) { return false; } 
	if (symbol === false) { return Math.round(converted * 100)/100; } 
	else { return '&#8363;'+(Math.round(converted * 100)/100);} 
	return false; 
} 

Save And Share :

5/06/2012

Formats for DateTime.ToString()

   1:  DateTime dt = DateTime.Now;
   2:  String strDate="";
   3:  strDate = dt.ToString("MM/dd/yyyy");   // 07/21/2007 
   4:  strDate = dt.ToString("dddd, dd MMMM yyyy");   //Saturday, 21 July 2007
   5:  strDate = dt.ToString("dddd, dd MMMM yyyy HH:mm"); // Saturday, 21 July 2007 14:58
   6:  strDate = dt.ToString("dddd, dd MMMM yyyy hh:mm tt"); // Saturday, 21 July 2007 03:00 PM
   7:  strDate = dt.ToString("dddd, dd MMMM yyyy H:mm"); // Saturday, 21 July 2007 5:01 
   8:  strDate = dt.ToString("dddd, dd MMMM yyyy h:mm tt"); // Saturday, 21 July 2007 3:03 PM
   9:  strDate = dt.ToString("dddd, dd MMMM yyyy HH:mm:ss"); // Saturday, 21 July 2007 15:04:10
  10:  strDate = dt.ToString("MM/dd/yyyy HH:mm"); // 07/21/2007 15:05
  11:  strDate = dt.ToString("MM/dd/yyyy hh:mm tt"); // 07/21/2007 03:06 PM
  12:  strDate = dt.ToString("MM/dd/yyyy H:mm"); // 07/21/2007 15:07
  13:  strDate = dt.ToString("MM/dd/yyyy h:mm tt"); // 07/21/2007 3:07 PM
  14:  strDate = dt.ToString("MM/dd/yyyy HH:mm:ss"); // 07/21/2007 15:09:29
  15:  strDate = dt.ToString("MMMM dd"); // July 21
  16:  strDate = dt.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"); // 2007-07-21T15:11:19.1250000+05:30    
  17:  strDate = dt.ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"); // Sat, 21 Jul 2007 15:12:16 GMT
  18:  strDate = dt.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"); // 2007-07-21T15:12:57
  19:  strDate = dt.ToString("HH:mm"); // 15:14
  20:  strDate = dt.ToString("hh:mm tt"); // 03:14 PM
  21:  strDate = dt.ToString("H:mm"); // 5:15
  22:  strDate = dt.ToString("h:mm tt"); // 3:16 PM
  23:  strDate = dt.ToString("HH:mm:ss"); // 15:16:29
  24:  strDate = dt.ToString("yyyy'-'MM'-'dd HH':'mm':'ss'Z'"); // 2007-07-21 15:17:20Z
  25:  strDate = dt.ToString("dddd, dd MMMM yyyy HH:mm:ss"); // Saturday, 21 July 2007 15:17:58
  26:  strDate = dt.ToString("yyyy MMMM"); // 2007 July

Save And Share :

5/04/2012

Replace multiple spaces in a string with special characters

The original string:   

What are   you looking    for ?

After using code:

what-are-you-looking-for?

 

Code Demo:

   1:         static void Main(string[] args)
   2:          {                        
   3:              string keyword = "What are   you   looking for ?";            
   4:              string abc = RegexReplaceMultiSpace(keyword).ToLower();            
   5:              Console.WriteLine();
   6:          }

 

   1:          public static string RegexReplaceMultiSpace(string input)
   2:          {
   3:              string space = " ";
   4:              string character = "-";
   5:              string result = Regex.Replace(input, string.Format("[{0}]+", space), character);             
   6:              result = result.Remove(result.LastIndexOf(character),1);
   7:              return result;
   8:          }

Save And Share :

 
  • Followers