Wednesday, 25 July 2012

Saturday, 21 July 2012

count occurrence of word in sentences JavaScript


       var temp = "This is a string.";

        // the g in the regular expression says to search the whole string
        // rather than just find the first occurrence
        var count = temp.match(/is/g);

        alert(count.length);
       
          (Or)
          alert(temp .split("is").length - 1);


       Result:
       1





Friday, 20 July 2012

SQL SERVER – Switch Between Two Parenthesis using Shortcut CTRL+]


SELECT *
FROM (SELECT *
FROM (SELECT *
FROM (SELECT *
FROM tbl_emp)a)b)c

Now press CTRL+] and you will see that it jumps from b to the opening parenthesis.

SELECT *
FROM (SELECT *
FROM (SELECT *
FROM (SELECT *
FROM tbl_emp)a)b)c

You can once again press CTRL+] and it will jump back to parenthesis after b.





CTRL+SHIFT+] Shortcut to Select Code Between Two Parenthesis

CTRL+SHIFT + ]   has selected the code between two corresponding parentheses.

SELECT *
FROM (SELECT *
FROM (SELECT *
FROM (SELECT *
FROM tbl_emp)a)b)c






Never regret. If it’s good, it’s wonderful. If it’s bad, it’s experience.




Monday, 16 July 2012

Error - Operation is not valid due to the current state of the object


Whenever a postback is done, this error occurs when form fields are very large in number. The stack trace is:
at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) at System.Web.HttpRequest.FillInFormCollection()
By default, the maximum value of MaxHttpCollection is 1000.
To solve this error, increase the MaxHttpCollection value. Try adding the following setting in yourweb.config's <appsettings> block.
  <appSettings>
      <add key="aspnet:MaxHttpCollectionKeys" value="3000" />
  </appSettings>
It can solve your problem. If you have very large records on your page, say 600 records in a grid, and you click on Submit, then increase the value of MaxHttpCollection.
Then change value 2000 to 5000 and test again. It will be resolved. :-)

Tuesday, 10 July 2012

determine if the OS is 32 bit or 64 bit in c#



int getOSArchitecture()
        {
            string pa = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
            return ((String.IsNullOrEmpty(pa) || String.Compare(pa, 0, "x86", 0, 3, true) == 0) ? 32 : 64);
        }