Friday, December 14, 2012

How to display currency in Javascript?

Number.prototype.formatMoney = function (c, d, t) {
    var n = this,
        c = isNaN(c = Math.abs(c)) ? 2 : c,
        d = d == undefined ? "," : d,
        t = t == undefined ? "." : t,
        s = n < 0 ? "-" : "",
        i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
        j = (j = i.length) > 3 ? j % 3 : 0;
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};

//Usage: 

(123456789.12345).formatMoney(2, '.', ',');

http://stackoverflow.com/questions/149055/how-can-i-format-numbers-as-money-in-javascript

Inline Editing With The WebGrid

http://www.mikesdotnetting.com/Article/202/Inline-Editing-With-The-WebGrid



Thursday, December 13, 2012

How disable a key by jQuery?

$('html').bind('keypress', function(e)
{
   if(e.keyCode == 80 || e.keyCode == 112)
   {
      return false;
   }
})

Wednesday, December 12, 2012

How to solve problem "Configuration file is not well-formed XML" in web.config with ampersand

replace ampersane & with &amp;

Why: web.config is in the format of XML 1.0:
The ampersand character (&) and the left angle bracket (<) may appear in their literal form only when used as markup delimiters, or within acomment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings "&amp;" and "&lt;" respectively