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 &

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

Monday, December 10, 2012

How to iterate an Enum in C#?

            Array values = Enum.GetValues(typeof(MyEnumType));
            foreach (MyEnumType val in values)
            {
                var enumName = Enum.GetName(typeof(MyEnumType), val);
            }

Why should not use Session variable for better performence in ASP.NET?

However, if two concurrent requests are made for the same session (by using the same SessionID value), the first request gets exclusive access to the session information. The second request executes only after the first request is finished. 

http://msdn.microsoft.com/en-au/library/ms178581(v=vs.100).aspx