Changhong's Technical Blog

  Home  |   Contact  |   Syndication    |   Login
  13 Posts | 0 Stories | 82 Comments | 3 Trackbacks

News

Archives

Post Categories

Blogs I read from kiwis...

Blogs I read...

February 2007 Entries

Had this question when I was reading “Effective C#: 50 Specific Ways to Improve Your C#”. In the item 18: "Implement the Standard Dispose Pattern", the book recommends to implements IDisposable.Dispose() to do following tasks: 1. Freeing all unmanaged resources. 2. Freeing all managed resource (this includes unhooking events). 3. … My question is on point 2, why do we have to unhook events? After having a look of how System.Delegate is implemented, I found the reason is actually quite simple. To...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

In my last post ViewState and Dynamic Control, I mentioned that ViewStateModeByIdAttribute can be used to change the default behavior of how ASP.NET finds the controls when ViewState data restored. Now, let's have a look how it can be done. For now, let's forget about ViewStateModeByIdAttribute for a second, and just have a simple page as following: Default.aspx <body> <form id="form1" runat="server"> <asp:Panel ID="pnlMain" runat="Server"> </asp:Panel> </form> </body>...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

I thought I understand ViewState, until I came cross this exception: 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. This is a question asked by someone on a .NET mailing list. My first guess of what causing the...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati