Jquery $(document).ready vs $(window).load

document.ready will execute after all HTML of the page is loaded.

window.load will wait for all elements are loaded, include image, iframe. window.load can be used in body onload.

$(document).ready will trigger before $(window).load. Use window.load when you want retrieve attribute of image, iframe on page start.

Leave a comment

Difference between String and string C#

The 'string' keyword is equivalent of 'System.String' so you don't need to using namespace System like following code.

//using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = string.Empty;
            System.String s2 = System.String.Empty;
            String s3 = String.Empty; // compile error namespace could not be found
        }
    }
}

Posted in | Leave a comment

Change default error message "The value ... is not valid for..."

This is my solution. Tested on MVC 3 and MVC 4.

  1. Create App_GlobalResources folder in project (easy way is right click to project -> Add -> Add ASP.NET folder -> App_GlobalResource).
  2. Add a resx file to App_GlobalResources (e.g. YourResource.resx).
  3. Add resource key "PropertyValueInvalid". By default, the message is "The value {0} is not valid for {1}". You can change or translate whatever you want.
  4. Add the code DefaultModelBinder.ResourceClassKey = "YourResource" to Application_Start function in Global.asax.

Posted in | Leave a comment

Search

Swedish Greys - a WordPress theme from Nordic Themepark. Converted by LiteThemes.com.