- Webparts are components within a webpage that can have their own personalization, positioning and event systems.
- Any control can be a webpart.
- Using webparts on ASP.NET pages requires ASPNETDB (a SQL Express) database to be used which keeps track of user personalizations for specific webparts.
- Webparts are placed inside WebpartZone controls that define an area within a page that contains or may contain webpart(s).
- Within WebpartZone control we need a ZoneTemplate to allow us to place standard controls within a zone.
- Webparts may be created by simply placing standard ASP.NET controls or even a user control inside the ZoneTemplate. The WebpartManager will take care of the rest.
- A WebpartManager control (non-visual) is required on every page that uses webparts (or any controls present in System.Web.UI.WebControls.Webparts). It handles events and other stuff related to the Webparts.
- Webparts may be displayed in various modes allowing users to view, design and even edit the webpart.
- We may switch between different webpart display modes by setting DisplayMode property to one of SupportedDisplayModes collection values of the WebPartManager class.
- Webparts within a same page may connected statically or dynamically.
- Static connections are the ones that are defined by the developer and cannt be modified or removed by the user. On the other hand, Dynamic Connections are modifiable by users.
- To create a static connection, we create a Provider class, a Consumer class and then tell the WebPartManager control about these two using StaticConnections markup within WebPartManager markup.
- The provider class should have a method decorated with ConnectionProvider attribute. Similarly, the consumer class should have a method decorated with ConnectionConsumer attribute. The value returned by the Provider method would go as argument into the Consumer method.
- For dynamic connections, all we need is to add a ConnectionsZone object to the page and enable the user to switch to Connect mode using WebPartManager. Once in this mode, the user can create or break connections between any existing Provider and Consumer.
- Personalization is enabled by default for WebParts, and it uses client-side Cookies to match the user with his/her record in ASPNETDB.
- If we wish to disable this personalization, we need to set WebPartManager.Personalization.Enabled property to false, either by using code or markup.
- We may also allow some users of the site to apply changes to WebPart page in such a way that the changes are visible to all users. This is called Shared Personalization.
- To enable Shared Personalization, we add authorization tag within
section of web.config file. Then we define allow tags to specify which users are allowed to do what to our page.
Monday, October 19, 2009
Chapter 5-Lesson 3
Labels:
ASPNETDB,
Connections,
Consumer,
Cookies,
Personalization,
Provider,
Webparts
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment