Monday, May 2, 2011

How to choose open source license by diagram

Just made a simple description of popular free software licenses


http://pbagwl.com/post/5078147450/description-of-popular-software-licenses

how to prevent the ASP.NET page being cached

Put following code into Page_Load
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);

How to solve "Failed to load viewstate" occasional problem for dynamically loading usercontrols in ASP.NET WebForms?


Full error message:
Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

How to replicate:
-Add a control dynamically to a placeholder and the control viewstate is enabled, and on the postback, add a different control to the placeholder.

Solution:
Add user control to a Panel, and Add Panel into placeholder
                placeholder.Controls.Clear();
                Panel p = new Panel();
                Control ctl = this.LoadControl(controlPath);
                ctl.ID = "uc" + i.ToString();
                i += 1;
                p.Controls.Add(ctl);
             placeholder.Controls.Add(p);


Reference:

http://forums.asp.net/p/1295517/2526944.aspx

How to understand jQuery source code

http://ejohn.org/apps/learn
By John Resig from jQuery
You can read and run source code, very same style javascript code like jQuery in this web site



Learning Advanced JavaScript

1) Our Goal
2) Defining Functions
3) Named Functions
4) Functions as Objects
5) Context
6) Instantiation
7) Flexible Arguments
8) Closures
9) Temporary Scope
10) Function Prototypes
11) Instance Type
12) Inheritance
13) Built-in Prototypes
14) Enforcing Function Context
15) Bonus: Function Length