Creating Web Parts New


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Hi Wpf team Questions strat V1 Wfc No idea
  • Creating Web Parts New

    1. 1. Creating Web Parts
    2. 2. Agenda <ul><li>Web Part (Base class) </li></ul><ul><ul><li>An ASP.NET web control </li></ul></ul><ul><ul><li>Browser Rendering </li></ul></ul><ul><ul><li>Rendering in non-browser clients </li></ul></ul><ul><ul><li>Overriding events </li></ul></ul><ul><li>Web Part Properties </li></ul><ul><ul><li>Introduction </li></ul></ul><ul><ul><li>Property attributes </li></ul></ul><ul><ul><li>Saving properties </li></ul></ul>
    3. 3. Agenda (Contd.) <ul><li>Creating a simple ‘Hello World’ Web Part, with a custom property </li></ul><ul><ul><li>Demo </li></ul></ul><ul><li>Tool parts </li></ul><ul><ul><li>Introduction </li></ul></ul><ul><ul><li>Methods </li></ul></ul><ul><ul><li>Demo </li></ul></ul>
    4. 4. Agenda (Contd.) <ul><li>Part to part connections </li></ul><ul><ul><li>Introduction </li></ul></ul><ul><ul><li>Interfaces </li></ul></ul><ul><li>Extending the framework </li></ul><ul><ul><li>Builders </li></ul></ul><ul><ul><li>Web Part menus </li></ul></ul><ul><ul><li>Tool pane </li></ul></ul><ul><li>Web Part Caching </li></ul><ul><ul><li>Introduction </li></ul></ul>
    5. 5. Web Part (Base class) <ul><li>Web Parts are ASP.NET Web Controls </li></ul><ul><ul><li>WebPart (base class) derives from System.Web.UI.Control </li></ul></ul><ul><ul><li>Like all controls they participate in: </li></ul></ul><ul><ul><ul><li>Page rendering </li></ul></ul></ul><ul><ul><ul><li>Property settings </li></ul></ul></ul><ul><ul><ul><li>Post-back events </li></ul></ul></ul><ul><ul><ul><li>State management </li></ul></ul></ul>Web Part = ASP.NET Web Control
    6. 6. Web Part (Base class) (Contd.) <ul><li>Browser Rendering </li></ul><ul><ul><li>The base class Render() method can’t be overridden. The base class uses this to render the chrome, title and web part menu </li></ul></ul><ul><ul><li>Custom Web Parts need to implement the RenderWebPart() method to render custom Html </li></ul></ul>
    7. 7. Web Part (Base class) (Contd.) <ul><li>Browser Rendering (Contd.) </li></ul>ASPX Page Web Part WebPart.Render() CustomPart.RenderWebPart() ASP.NET starts page render Request
    8. 8. The Web Part base class (Contd.) <ul><li>Rendering in non-browser clients </li></ul><ul><ul><li>IDesignTimeHtmlProvider interface is used to obtain the rendering for the web part when added to page in clients like FrontPage </li></ul></ul><ul><ul><li>IDesignTimeHtmlProvider consists of one method: GetDesignTimeHtml </li></ul></ul><ul><ul><li>Not implemented by default </li></ul></ul>
    9. 9. The Web Part base class (Contd.) <ul><li>Overriding Events </li></ul><ul><ul><li>The following ASP.Net events are sealed: </li></ul></ul><ul><ul><ul><li>OnInit , OnDataBinding , OnLoad, OnPreRender, OnUnload </li></ul></ul></ul><ul><ul><ul><li>To subscribe to these events the developer will use: </li></ul></ul></ul><ul><ul><ul><li>this.Load += new EventHandler (myLoadEvent); </li></ul></ul></ul>
    10. 10. Web Part Properties <ul><li>Introduction </li></ul><ul><ul><li>Web Parts have ‘properties’ that help the user define their behavior </li></ul></ul><ul><ul><li>Two kinds of properties: </li></ul></ul><ul><ul><ul><li>Base class properties </li></ul></ul></ul><ul><ul><ul><li>Custom properties </li></ul></ul></ul><ul><ul><li>All properties must be serializable through the XMLSerializer </li></ul></ul><ul><ul><li>Property attributes define property behavior </li></ul></ul>
    11. 11. Web Part Properties (Contd.) <ul><li>Property attributes </li></ul><ul><ul><li>Browsable (.Net) </li></ul></ul><ul><ul><li>Category (.Net) </li></ul></ul><ul><ul><li>Description (.Net) </li></ul></ul><ul><ul><li>- Etc. - </li></ul></ul><ul><ul><li>FriendlyName (Web Part Framework) </li></ul></ul><ul><ul><li>HtmlDesigner (Web Part Framework) </li></ul></ul><ul><ul><li>WebPartStorage (Web Part Framework) </li></ul></ul><ul><ul><li>- Etc. - </li></ul></ul>
    12. 12. Web Part Properties (Contd.) <ul><li>Saving Properties </li></ul><ul><ul><li>Properties are serialized and stored in the database </li></ul></ul><ul><ul><li>Stored in two contexts: </li></ul></ul><ul><ul><ul><li>Shared </li></ul></ul></ul><ul><ul><ul><li>Personal </li></ul></ul></ul><ul><ul><li>Storage is controlled by the WebPartStorage attribute: </li></ul></ul><ul><ul><ul><li>WebPartStorage = Storage.Shared </li></ul></ul></ul><ul><ul><ul><li>WebPartStorage = Storage.Personal </li></ul></ul></ul><ul><ul><ul><li>WebPartStorage = Storage.None </li></ul></ul></ul>
    13. 13. Creating a simple ‘Hello World’ Web Part, with a custom property
    14. 14. Tool parts <ul><li>An Introduction </li></ul><ul><ul><li>Also derive from Web Controls and should be used to add custom functionality to the tool pane </li></ul></ul><ul><ul><li>Differ from web parts </li></ul></ul><ul><ul><ul><li>No mobility </li></ul></ul></ul><ul><ul><ul><li>Limited base class property set </li></ul></ul></ul><ul><ul><ul><li>No property storage </li></ul></ul></ul><ul><ul><ul><li>Render only in the tool pane </li></ul></ul></ul><ul><ul><li>Rendering process similar to web parts </li></ul></ul><ul><ul><ul><li>ToolPart.Render cannot be overridden </li></ul></ul></ul><ul><ul><ul><li>Implement RenderToolPart </li></ul></ul></ul>
    15. 15. Tool parts (Contd.) <ul><li>Important Methods </li></ul><ul><ul><li>ToolPart.ApplyChanges() </li></ul></ul><ul><ul><ul><li>Called when the user clicks Apply/ Ok on the property sheet </li></ul></ul></ul><ul><ul><li>ToolPart.CancelChanges() </li></ul></ul><ul><ul><ul><li>Called when the user clicks Cancel on the property sheet </li></ul></ul></ul><ul><ul><li>ToolPart.SyncChanges() </li></ul></ul><ul><ul><ul><li>Called when the tool part needs to refresh itself. (example: after another tool part has saved properties) </li></ul></ul></ul><ul><ul><li>WebPart.GetToolParts </li></ul></ul><ul><ul><ul><li>Method on the web part base class </li></ul></ul></ul><ul><ul><ul><li>Used to associate tool parts with web parts </li></ul></ul></ul>
    16. 16. Creating a custom tool part
    17. 17. Part to part connections <ul><li>An Introduction </li></ul><ul><ul><li>Allows Web Parts to send & received basic types of data; e.g. Cell, Row, List, etc. </li></ul></ul><ul><ul><li>Uses standardized set of interfaces </li></ul></ul><ul><ul><li>Allows completely independent parts to connect </li></ul></ul><ul><ul><li>Enables end users to form connections </li></ul></ul><ul><ul><ul><li>Browser </li></ul></ul></ul><ul><ul><ul><li>FrontPage </li></ul></ul></ul>
    18. 18. Part to part connections (Contd.) My Web Part Page
    19. 19. Part to part connections (Contd.) <ul><li>Interfaces </li></ul><ul><ul><li>ICellProvider, ICellConsumer </li></ul></ul><ul><ul><li>IRowProvider, IRowConsumer </li></ul></ul><ul><ul><li>IListProvider, IListConsumer </li></ul></ul><ul><ul><li>IFilterProvider, IFilterConsumer </li></ul></ul><ul><ul><li>IParametersOutProvider, IParametersOutConsumer </li></ul></ul><ul><ul><li>IParametersInProvider, IParametersInConsumer </li></ul></ul>