Sunday, May 11, 2008

Web Part Personalization

Customization

  • All users with sufficient permission to modify the web part in public shared views
  • PersonalizationScope.Shared

Personalization

  • Modifications apply to the view of the modifying user only
  • PersonalizationScope.User

Exposing Properties to Customize

  • Decorate public properties with attributes
    • Personalizable: controls personalization scope
    • WebBrowsable: causes the property to display in the web part editor
    • WebDisplayName: human readable, localized name of the property
    • WebDescription: localizable description of the property
    • Category: text used to group related properties in the web part editor

OnPreRender

  • When OnPreRender happens
    • All controls are fully loaded on the page.
    • ViewState is loaded and control values are current.
    • ViewState is not saved and can still be changed.
    • Last chance to change properties of controls before rendering take place.
  • OnPreRender Uses
    • Update control properties based on personalization properties
    • Get data from the database
    • Make web service calls
    • Connect data binding
    • Do stuff that depends on the state and values of ChildControls
    • RegisterClientScipt
blog comments powered by Disqus