Home Sign In

Steven Van de Craen's Blog [MVP]

Bloggings about SharePoint, .NET and more.

MVP SharePoint Server

RSS Feed
  • Contact Me

Archives

July 2007 (19)
August 2007 (5)
April 2008 (4)
September 2007 (3)
November 2007 (12)
October 2007 (4)
December 2007 (8)
January 2008 (6)
February 2008 (3)
March 2008 (4)
June 2008 (3)
July 2008 (1)
August 2008 (2)
September 2008 (2)
October 2008 (5)
November 2008 (3)

Categories

  • SharePoint 2003
  • SharePoint 2007
  • General
  • Office 2003
  • Office 2007
  • Excel Services
  • Dynamics NAV
  • SOAP
  • Search
  • Search Server 2008
  • .NET
  • CKS
  • IIS
  • VBA
  • Forms Server
  • SharePoint Updates

Recent Posts

  • SharePoint and jQuery coolness
  • SharePoint: Sharing data over applications ?
  • SharePoint 2007 and ZIP indexing
  • Infrastructure Update, August Update, October Update, Service Pack 2
  • Forms Server: userName() function and Forms Based Authentication

Other Blogs

//BLOG: naked programmer
JOPX
Jan Tielens' Bloggings [MVP]
Serge van den Oever [Macaw]
Carlos Segura Sanz
Remco Ploeg's Blog
SharePoint Blogs
Romeo Pruno
Andrew Connell [MVP MOSS]
Mark Harrison
Pedro Serrano
Clemens Vasters and the Indigettes
Kevin Boske
SharePoint Team Blog
Brian Jones: Office XML Formats
Mart Muller's Sharepoint Weblog
Joel Oleson's SharePoint Land
Kris' blog
STSADM Custom Extensions
Microsoft Enterprise Search Blog
Michaël's coding thoughts
Chris O'Brien's blog
John Holliday's SharePoint Reflections
Koen's blog
PDT IT Services Blog Posts
.net palace (Benjamin Geens)
Mike Walsh's WSS and more
Patrik Luca's Blog
deyaert's blog

ASP.NET WebPart Life Cycle reminder (repost)

I'm currently programming some connectable Web Parts for MOSS 2007 and want to make this a small note to self:

Web Part Life Cycle on page load

  1. OnInit
  2. OnLoad
  3. Connection Consuming
  4. CreateChildControls
  5. OnPreRender
  6. Render (RenderContents, etc)

Web Part Life Cycle on button click

  1. OnInit
  2. CreateChildControls
  3. OnLoad
  4. Click Event Handling
  5. Connection Consuming
  6. OnPreRender
  7. RenderContents

Keep this in mind because if you set a variable in the 'Connection Consuming' step, you can only access it after the step has occurred. So if you want to use it before that step you must store it in ViewState/Cache/other.

 
Categories: General

Trackback Url

 

Comments

Thursday, 27 Dec 2007 07:53 by Mattias Waldau
Why not call CreateChildControls again from your button? Add the following code to the end of your button code. this.Controls.Clear(); CreateChildControls();

Thursday, 27 Dec 2007 07:53 by Steven Van de Craen
Mattias, are there any implications regarding ViewState loading when going for that approach ? I would just create a method for settings the controls enabled state (based on the business logic) and call that in both the CreateChildControls and OnClick. That way you're not double running every line of code in the CreateChildControls.

Thursday, 27 Dec 2007 07:53 by
Thank you for the post. Is there a way to invert Click Event Handling with Connection Consuming? Or to force the Connection Consuming in Page Load?

Thursday, 27 Dec 2007 07:53 by Steven Van de Craen
Hi, AFAIK you cannot change the order of the lifecycle events. It agree that it would make life a lot easier but your best option would be to store the data in a temporary cache. Regards, Steven

Thursday, 27 Dec 2007 07:53 by teddy
Hi Steven, I have tried all I know but with no chance. I have a set of controls in a MOSS 2007 web part. I have some controls which are updated with enable/disable from the database values. The database values are saved by me clicking on a button from the webpart. Because Click Event Handling is after CreateChildControls I have no idea on how to make the controls enabled or disabled. Please help if you can. Thanks in advance, Teddy

Leave a comment

Name

Url

Email

Comments

CAPTCHA Image Validation

© 2007 Steven Van de Craen — Powered by Community Kit for SharePoint: Enhanced Blog Edition.