Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Sofia, Bulgaria | 9-10 October ASP.NET: Developing Portal UI With Web Parts Goksin Bakir Yage Ltd Microsoft Regional Director, MEA Agenda ● Web Part Lifecycle ● Extending Personalization ● Connections ● Securing your Infrastructure ● Managing Personalized Data Sofia, Bulgaria | 9-10 October Components ● WebPartManager ● WebPartZones and Web Parts ● CatalogZones and CatalogParts ● EditorZones and EditorParts ● Web Part connections ● Web Part personalization ● Custom Web Parts Sofia, Bulgaria | 9-10 October Web Parts ● Framework for building portal-style apps ● Patterned after SharePoint Portal Server ● System.Web.UI.WebControls.WebParts ● Rich UIs with minimal code ● Edit page layout using drag-and-drop ● Edit appearance and behavior and more ● Seamless personalization ● Intercommunication ("connections") Sofia, Bulgaria | 9-10 October The WebPartManager Control ● Orchestrates operation of Web Parts ● Maintains list of Web Parts and zones ● Manages page state (e.g., display mode) and fires events when page state changes ● Facilitates communication between Web Parts ● Manages personalization and much more ● One instance per page; no UI <asp:WebPartManager ID="WebPartManager1" RunAt="server" /> Sofia, Bulgaria | 9-10 October The WebPartZone Control ● Defines zones on a Web Parts page ● Defines default layout and appearance of Web Parts within each zone <asp:WebPartZone ID="WeatherZone" DragHighlightColor="244,198,96" RunAt="server"> <PartTitleStyle BackColor="#2254B1" ForeColor="White" /> <PartStyle BorderColor="#81AAF2" BorderStyle="Solid" BorderWidth="1px" /> <ZoneTemplate> <!-- Web Parts declared here --> </ZoneTemplate> </asp:WebPartZone> Sofia, Bulgaria | 9-10 October Web Part Zones Zone 1 Zone 2 Sofia, Bulgaria | 9-10 October Web Part Chrome ● Title bar and border surrounding Web Part ● Look defined by WebPartZone properties Title Bar Verbs Button Border Minimize Verb Close Verb Verbs Menu Sofia, Bulgaria | 9-10 October Web Parts ● Controls defined in a WebPartZone ● Web controls, user controls, custom controls ● Controls that don't implement IWebPart are internally wrapped in GenericWebParts ● Adds properties: Title, Description, etc. <ZoneTemplate> <asp:Calendar Title="Calendar" ID="Calendar1" RunAt="server" /> <user:Weather Title="Weather" ID="Weather1" RunAt="server" /> <custom:Search Title="Search" ID="Search1" RunAt="server" /> </ZoneTemplate> Sofia, Bulgaria | 9-10 October Web Parts Stocks Web Part News Web Part Weather Web Part Search Web Part Calendar Web Part Sofia, Bulgaria | 9-10 October Sofia, Bulgaria | 9-10 October Web Parts Know The Web Part Life Cycle To Do The Right Thing At The Right Time Sofia, Bulgaria | 9-10 October Web Part Lifecycle ● PreInit ● Init ● InitComplete ● LoadViewState ● Load ● LoadComplete ● PreRender ● WebZones register with the WebPartManager ● Static WebParts are loaded ● Dynamic WebParts and connections are loaded ● Personalization data applied to Web Pars ● Web Part connections are activated ● SaveStateComplete ● Render ● Extract & save personalization data Sofia, Bulgaria | 9-10 October Web Part Lifecycle Common developer scenarios Action After Before Suggested Add WebZone WebPartManager initialized Personalization Page.Init data is applied Add Static Web Part Zones registered Personalization Page.Init data is applied Add Dynamic Web Part Personalization data is applied Personalization data is saved Add Connections Dynamic Web Part loaded Connections are activated Page.InitComplete Page.Load Sofia, Bulgaria | 9-10 October Sofia, Bulgaria | 9-10 October Externally Defined Web Parts And Connections Web Parts Personalization Is Extensible At Many Levels Sofia, Bulgaria | 9-10 October Extending Personalization Override existing providers ● Implement custom load and save logic ● Encryption, query string, caching ● Use the data store from the base class ● Existing providers ● SQL Personalization Provider in the box ● Access provider available via the Web protected override void LoadPersonalizationBlobs(...) { // custom logic here (i.e. decrypt data) base.LoadPersonalizationBlobs(..) } protected override void SavePersonalizationBlob(...) { // custom logic here (i.e. encrypt data) base.SavePersonalizationBlob(..) } Sofia, Bulgaria | 9-10 October Extending Personalization Override provider base class ● Support different data store ● Web Service, XML, Oracle ● Integrate to an existing application ● Only need to manage the storage of the personalization blob public abstract class PersonalizationProvider : ProviderBase { protected abstract void LoadPersonalizationBlobs(...); protected abstract void SavePersonalizationBlob(...); public abstract int ResetState(...); public abstract PersonalizationStateInfoCollection FindState(...); } Sofia, Bulgaria | 9-10 October Extending Personalization Override personalization engine ● Take ownership of the personalization process ● Save and restore personalizable property values (diff & merge) ● Supporting the personalization Interfaces ● Track Web Part dirty state ● Use when previous options do not work public class WebPartPersonalization { protected virtual PersonalizationScope Load(); protected virtual void ApplyPersonalizationState(WebPart webPart); protected virtual void ExtractPersonalizationState(WebPart webPart); protected virtual void Save(); } Sofia, Bulgaria | 9-10 October Sofia, Bulgaria | 9-10 October Creating A Web Site Content Management Application Changing Connection Behavior At Runtime Sofia, Bulgaria | 9-10 October Connections Disable connection point ● Must be defined at compile time but can be disabled at runtime ● Can not create new connections ● Existing connections will display an error public class SampleConsumer : WebPart { [ConnectionConsumerAttribute(“Data”, typeof(ExtendedConnectionPoint))] public void GetProviderInterface(ProviderInterface provider); } public class ExtendedConnectionPoint : ConsumerConnectionPoint { public override bool GetEnabled(Control control) { // enable logic here (i.e. disable if SQL Server is down) } } Sofia, Bulgaria | 9-10 October Sofia, Bulgaria | 9-10 October Sofia, Bulgaria | 9-10 October Providing Rich Information Via Connections Portals Have Unique Security Considerations Sofia, Bulgaria | 9-10 October Securing Your Infrastructure Restrict contents of uploaded page ● Use the PageParserFilter feature ● Disallow code ● Restrict server controls ● Limit the number of controls on the page ● Enforce page base type and page directives ● All checks are performed at parse time public abstract class PageParserFilter { public virtual bool AllowCode { get; } public virtual bool AllowControl(Type controlType, ControlBuilder builder); public virtual int NumberOfControlsAllowed { get; } public virtual bool AllowBaseType(Type baseType); public virtual void PreprocessDirective(string name, IDictionary attributes); } Sofia, Bulgaria | 9-10 October Securing Your Infrastructure Restrict Web Parts at runtime ● Based on the Web Part type and/or AuthorizationFilter property ● Example : Filter by user role ● Applies to all web parts on the page ● The personalized data is not disposed ● Subscribe to AuthorizeWebPart event or override IsAuthorized method public abstract class WebPartManager { public virtual bool IsAuthorized(Type type, string path, string authorizationFilter, bool isShared); } Sofia, Bulgaria | 9-10 October Sofia, Bulgaria | 9-10 October Sofia, Bulgaria | 9-10 October Implementing Secure Import/Export Portal Users Need Self Management Tools Sofia, Bulgaria | 9-10 October Managing Personalized Data Page level ● ● ● ● ● PersonalizationAdministration class High level APIs to manage all data Works at the page level, not web part level Works with any Personalization Provider Self management tool must enforce security public static class PersonalizationAdministration { public static int GetCountOfUserState(string usernameToMatch); public static PersonalizationStateInfoCollection FindUserState ( string pathToMatch, string usernameToMatch); public static bool ResetUserState(string path, string username); public static int ResetInactiveUserState(DateTime userInactiveSinceDate); } Sofia, Bulgaria | 9-10 October Managing Personalized Data Web Part level ● Run target page within management page ● Attach to an event in the target page ● Based on Web Part lifecycle ● Execute code within event handler ● Example: call WebPartManager APIs like DeleteWebPart() or CloseWebPart() ● Target page will save personalized data Sofia, Bulgaria | 9-10 October Sofia, Bulgaria | 9-10 October Creating An Admin Page Call To Action ● Use Web Part control to empower user customization of their site ● Work with the Web Part Lifecycle ● Use the Web Part control set when building Module User Interfaces Sofia, Bulgaria | 9-10 October Community Resources ●INETA MEA ! ●www.ineta.org ●mea.ineta.org ●ASP.NET Web Site - http://www.asp.net ●MSDN dev center http://msdn.microsoft.com/asp.net/ ●ASP.NT Forums http://forums.asp.net/145/ShowForum.aspx ●Channel 9 tag Sofia, Bulgaria | 9-10 October http://channel9.msdn.com/tags/ASP.NET Call To Action ● Use Web Part control to empower user customization of their site ● Work with the Web Part Lifecycle ● Use the Web Part control set when building Module User Interfaces Sofia, Bulgaria | 9-10 October Community Resources ●INETA MEA ! ●www.ineta.org ●mea.ineta.org ●ASP.NET Web Site - http://www.asp.net ●MSDN dev center http://msdn.microsoft.com/asp.net/ ●ASP.NT Forums http://forums.asp.net/145/ShowForum.asp Sofia, Bulgaria | 9-10 October Sofia, Bulgaria | 9-10 October Please fill out the survey forms! They are the key to amazing prizes that you can get at the end of each day Thank you! Sofia, Bulgaria | 9-10 October