Create Web Part by inserting standard ASP.NET control within
Web Parts can be displayed to user in several ways - depends on what user is doing with the Web Parts and hosting page.
|BrowseDisplayMode||Standard way to browse web pages - default|
|DesignDisplayMode||Allows users to drag Web Parts to new locations|
|EditDisplayMode||In addition to dragging, users can edit title, size, direction, appearance and zone of Web Part controls. To use this mode, must add EditorZone control to web page along with either (or both) AppearanceEditorPart and LayoutEditorPart|
|CatalogDisplayMode||Allow users to add Web Parts specified by CatalogZone control (which must also be present on page)|
|ConnectDisplayMode||Allows users to establish connections between controls using ConnectionZone control, e.g. Web Parts can be linked to show summary and detail information for same report.|
Code to change mode:
string mode = (string)ViewState["mode"];
if (mode == "browse")
WebPartManager1.DisplayMode = WebPartManager1.SupportedDisplayModes["Catalog"];
WebPartManager1.DisplayMode = WebPartManager1.SupportedDisplayModes["Browse"];
Application may consist of:
With Web Part connections can select employee file and have all other parts automatically update their display.
Useful for consumer oriented sites, e.g. portal site may display localised info based on users post code.
Developer establishes connection during development process - cannot be changed by user.
<asp:WebPartManager ID="WebPartManager1" runat="server">
<asp:webPArtConnection ID="conn1", ProviderID="prov1", ProviderConnectionPointID="GetTextBoxValue", ConsumerID="cons1", ConsumerConnectionPointID="ShowTextBoxValue" />
Established by users.
Enabled by adding ConnectionsZone control to webpage.
User follows these steps:
Switch display mode to ConnectDisplayMode
On Web Parts menu of provider or consumer select Connection
ConnectionZone object appears
If existing connection exists click Disconnect to break it
Click close. Web parts connected as if they were connected statically.
Personalisation automatically stores location and other personalised Web Parts.
Can also store custom data in personalisation database.
To store custom data define properties on control representing custom data and apply the Personalizable attribute to them.
Web Parts personalisation enabled by default, authenticated users able to personalise pages for themselves without any special configuration. These changes only visible to user who made them.
To allow a user to make changes that are visible to others need to enable shared personalisation in web.config file. Within system.web add authorization section which contains an allow element specifying which user(s) have access to shared personalisation:
<allow verbs="get" users="SomeUserAccount" roles="admin" />`
? in users grants access to anonymous users, whilst * allows everyone.
roles attribute specifies the roles that are granted access to resource
verbs provide HTTP transmission methods (get, head, post, debug) granted access to resource
Can disable on individual pages by setting the WebPartManager.Personalisation.Enabled attribute to false.