sofia, bulgaria | 9-10 october asp.net: developing portal ui with web parts goksin bakir yage ltd...
TRANSCRIPT
Sofia, Bulgaria | 9-10 OctoberSofia, Bulgaria | 9-10 October
ASP.NET: Developing Portal UI
With Web Parts
ASP.NET: Developing Portal UI
With Web Parts
Goksin Bakir
Yage Ltd
Microsoft Regional Director, MEA
Goksin Bakir
Yage Ltd
Microsoft Regional Director, MEA
Sofia, Bulgaria | 9-10 October
AgendaAgenda
● Web Part Lifecycle
● Extending Personalization
● Connections
● Securing your Infrastructure
● Managing Personalized Data
● Web Part Lifecycle
● Extending Personalization
● Connections
● Securing your Infrastructure
● Managing Personalized Data
Sofia, Bulgaria | 9-10 October
ComponentsComponents
● WebPartManager
● WebPartZones and Web Parts
● CatalogZones and CatalogParts
● EditorZones and EditorParts
● Web Part connections
● Web Part personalization
● Custom Web Parts
● 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 PartsWeb 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")
● 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 ControlThe 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
● 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 ControlThe WebPartZone Control
● Defines zones on a Web Parts page
● Defines default layout and appearance of Web Parts within each zone
● 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" 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 ZonesWeb Part Zones
Zone 1 Zone 2
Sofia, Bulgaria | 9-10 October
Web Part ChromeWeb Part Chrome● Title bar and border surrounding Web
Part
● Look defined by WebPartZone properties
Title Bar Minimize VerbClose Verb
Verbs MenuBorder
Verbs Button
Sofia, Bulgaria | 9-10 October
Web PartsWeb 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.
● 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 PartsWeb Parts
SearchWeb Part
StocksWeb Part
NewsWeb Part
WeatherWeb Part
CalendarWeb Part
Sofia, Bulgaria | 9-10 OctoberSofia, Bulgaria | 9-10 October
Web PartsWeb Parts
Sofia, Bulgaria | 9-10 October
Know The Web Part Life Cycle To Do The Right Thing At The Right Time
Know The Web Part Life Cycle To Do The Right Thing At The Right Time
Sofia, Bulgaria | 9-10 October
● PreInit
● Init
● InitComplete
● LoadViewState
● Load
● LoadComplete
● PreRender
● SaveStateComplete
● Render
● PreInit
● Init
● InitComplete
● LoadViewState
● Load
● LoadComplete
● PreRender
● SaveStateComplete
● Render
Web Part LifecycleWeb Part Lifecycle
● 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
● Extract & save personalization data
Sofia, Bulgaria | 9-10 October
Web Part Lifecycle Common developer scenariosWeb Part Lifecycle Common developer scenarios
Action After Before Suggested
Add WebZone WebPartManager initialized
Personalization data is applied
Page.Init
Add Static Web Part Zones registered Personalization data is applied
Page.Init
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 OctoberSofia, Bulgaria | 9-10 October
Externally Defined Web Parts
And Connections
Externally Defined Web Parts
And Connections
Sofia, Bulgaria | 9-10 October
Web Parts Personalization Is Extensible At Many LevelsWeb Parts Personalization Is Extensible At Many Levels
Sofia, Bulgaria | 9-10 October
Extending PersonalizationOverride existing providersExtending PersonalizationOverride 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
● 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(...) {protected override void LoadPersonalizationBlobs(...) { // custom logic here (i.e. decrypt data)// custom logic here (i.e. decrypt data) base.LoadPersonalizationBlobs(..)base.LoadPersonalizationBlobs(..)}}
protected override void SavePersonalizationBlob(...) {protected override void SavePersonalizationBlob(...) { // custom logic here (i.e. encrypt data)// custom logic here (i.e. encrypt data) base.SavePersonalizationBlob(..)base.SavePersonalizationBlob(..)}}
Sofia, Bulgaria | 9-10 October
Extending Personalization Override provider base classExtending 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
● 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 {public abstract class PersonalizationProvider : ProviderBase { protected abstract void LoadPersonalizationBlobs(...);protected abstract void LoadPersonalizationBlobs(...); protected abstract void SavePersonalizationBlob(...);protected abstract void SavePersonalizationBlob(...); public abstract int ResetState(...);public abstract int ResetState(...); public abstract PersonalizationStateInfoCollection FindState(...);public abstract PersonalizationStateInfoCollection FindState(...);}}
Sofia, Bulgaria | 9-10 October
Extending Personalization Override personalization engineExtending 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
● 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 {public class WebPartPersonalization { protected virtual PersonalizationScope Load();protected virtual PersonalizationScope Load(); protected virtual void ApplyPersonalizationState(WebPart webPart);protected virtual void ApplyPersonalizationState(WebPart webPart); protected virtual void ExtractPersonalizationState(WebPart webPart);protected virtual void ExtractPersonalizationState(WebPart webPart); protected virtual void Save();protected virtual void Save();}}
Extending Personalization Override personalization engineExtending Personalization Override personalization engine
Sofia, Bulgaria | 9-10 OctoberSofia, Bulgaria | 9-10 October
Creating A Web Site Content Management
Application
Creating A Web Site Content Management
Application
Sofia, Bulgaria | 9-10 October
Changing Connection Behavior At RuntimeChanging Connection Behavior At Runtime
Sofia, Bulgaria | 9-10 October
ConnectionsDisable connection pointConnectionsDisable 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
● 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 {public class SampleConsumer : WebPart { [ConnectionConsumerAttribute(“Data”, typeof(ExtendedConnectionPoint))][ConnectionConsumerAttribute(“Data”, typeof(ExtendedConnectionPoint))] public void GetProviderInterface(ProviderInterface provider);public void GetProviderInterface(ProviderInterface provider);}}
public class ExtendedConnectionPoint : ConsumerConnectionPoint {public class ExtendedConnectionPoint : ConsumerConnectionPoint { public override bool GetEnabled(Control control) {public override bool GetEnabled(Control control) { // enable logic here (i.e. disable if SQL Server is down) // enable logic here (i.e. disable if SQL Server is down) }}}}
Sofia, Bulgaria | 9-10 October
Sofia, Bulgaria | 9-10 OctoberSofia, Bulgaria | 9-10 October
Providing Rich Information
Via Connections
Providing Rich Information
Via Connections
Sofia, Bulgaria | 9-10 October
Portals Have Unique Security ConsiderationsPortals Have Unique Security Considerations
Sofia, Bulgaria | 9-10 October
Securing Your InfrastructureRestrict contents of uploaded pageSecuring Your InfrastructureRestrict 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
● 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 abstract class PageParserFilter { public virtual bool AllowCode { get; }public virtual bool AllowCode { get; } public virtual bool AllowControl(Type controlType, ControlBuilder builder);public virtual bool AllowControl(Type controlType, ControlBuilder builder); public virtual int NumberOfControlsAllowed { get; }public virtual int NumberOfControlsAllowed { get; } public virtual bool AllowBaseType(Type baseType);public virtual bool AllowBaseType(Type baseType); public virtual void PreprocessDirective(string name, IDictionary attributes);public virtual void PreprocessDirective(string name, IDictionary attributes);}}
Sofia, Bulgaria | 9-10 October
Securing Your InfrastructureRestrict Web Parts at runtimeSecuring Your InfrastructureRestrict 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
● 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 abstract class WebPartManager { public virtual bool IsAuthorized(Type type, string path, public virtual bool IsAuthorized(Type type, string path, string authorizationFilter, bool isShared);string authorizationFilter, bool isShared); }}
Sofia, Bulgaria | 9-10 October
Sofia, Bulgaria | 9-10 OctoberSofia, Bulgaria | 9-10 October
Implementing Secure Import/Export
Implementing Secure Import/Export
Sofia, Bulgaria | 9-10 October
Portal Users Need Self Management ToolsPortal Users Need Self Management Tools
Sofia, Bulgaria | 9-10 October
Managing Personalized DataPage levelManaging Personalized DataPage 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
● 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 class PersonalizationAdministration { public static int GetCountOfUserState(string usernameToMatch);public static int GetCountOfUserState(string usernameToMatch); public static PersonalizationStateInfoCollection FindUserState (public static PersonalizationStateInfoCollection FindUserState ( string pathToMatch, string usernameToMatch);string pathToMatch, string usernameToMatch); public static bool ResetUserState(string path, string username);public static bool ResetUserState(string path, string username); public static int ResetInactiveUserState(DateTime userInactiveSinceDate);public static int ResetInactiveUserState(DateTime userInactiveSinceDate);}}
Sofia, Bulgaria | 9-10 October
Managing Personalized DataWeb Part levelManaging Personalized DataWeb 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
● 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 OctoberSofia, Bulgaria | 9-10 October
Creating An Admin PageCreating An Admin Page
Sofia, Bulgaria | 9-10 October
Call To ActionCall 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
● 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 ResourcesCommunity 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 - http://channel9.msdn.com/tags/ASP.NET
●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 - http://channel9.msdn.com/tags/ASP.NET
Sofia, Bulgaria | 9-10 October
Call To ActionCall 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
● 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 ResourcesCommunity 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 - http://channel9.msdn.com/tags/ASP.NET
●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 - http://channel9.msdn.com/tags/ASP.NET
Sofia, Bulgaria | 9-10 OctoberSofia, 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
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!Thank you!
Sofia, Bulgaria | 9-10 OctoberSofia, Bulgaria | 9-10 October