Creating Web Parts New
-
Upload
pradeep-sripada -
Category
Technology
-
view
872 -
download
2
description
Transcript of Creating Web Parts New
Creating Web PartsCreating Web Parts
AgendaAgenda
Web Part (Base class) Web Part (Base class) An ASP.NET web controlAn ASP.NET web control Browser RenderingBrowser Rendering Rendering in non-browser clientsRendering in non-browser clients Overriding eventsOverriding events
Web Part PropertiesWeb Part Properties IntroductionIntroduction Property attributesProperty attributes Saving propertiesSaving properties
Agenda (Contd.)Agenda (Contd.)
Creating a simple ‘Hello World’ Creating a simple ‘Hello World’ Web Part, with a custom Web Part, with a custom propertyproperty DemoDemo
Tool partsTool parts IntroductionIntroduction MethodsMethods DemoDemo
Agenda (Contd.)Agenda (Contd.) Part to part connectionsPart to part connections
Introduction Introduction InterfacesInterfaces
Extending the frameworkExtending the framework BuildersBuilders Web Part menusWeb Part menus Tool paneTool pane
Web Part CachingWeb Part Caching IntroductionIntroduction
Web Part (Base class)Web Part (Base class) Web Parts are ASP.NET Web ControlsWeb Parts are ASP.NET Web Controls
WebPart WebPart (base class) derives from(base class) derives from System.Web.UI.ControlSystem.Web.UI.Control
Like all controls they participate in:Like all controls they participate in: Page rendering Page rendering Property settingsProperty settings Post-back eventsPost-back events State managementState management
Web Part = ASP.NET Web Web Part = ASP.NET Web ControlControl
Web Part (Base class) Web Part (Base class) (Contd.)(Contd.) Browser RenderingBrowser Rendering
The base classThe base class Render()Render() method can’t method can’t be overridden. The base class uses this be overridden. The base class uses this to render the chrome, title and web to render the chrome, title and web part menupart menu
Custom Web Parts need to implement Custom Web Parts need to implement thethe RenderWebPart()RenderWebPart() method to render method to render custom Htmlcustom Html
Web Part (Base class) Web Part (Base class) (Contd.)(Contd.) Browser Rendering (Contd.)Browser Rendering (Contd.)
ASPX ASPX PagePage
Web Part WebPart.Rende
r()
CustomPart.RenderWebPart()
ASP.NET starts page render
RequestRequest
The Web Part base class The Web Part base class (Contd.)(Contd.) Rendering in non-browser clientsRendering in non-browser clients
IDesignTimeHtmlProviderIDesignTimeHtmlProvider interface is interface is used to obtain the rendering for the used to obtain the rendering for the web part when added to page in web part when added to page in clients like FrontPageclients like FrontPage
IDesignTimeHtmlProvider consists of IDesignTimeHtmlProvider consists of one method:one method: GetDesignTimeHtmlGetDesignTimeHtml
Not implemented by defaultNot implemented by default
The Web Part base class The Web Part base class (Contd.)(Contd.) Overriding EventsOverriding Events
The following ASP.Net events are sealed:The following ASP.Net events are sealed: OnInitOnInit , , OnDataBindingOnDataBinding, , OnLoad, OnLoad,
OnPreRender, OnUnloadOnPreRender, OnUnload
To subscribe to these events the To subscribe to these events the developer will use: developer will use: this.Load += new EventHandler this.Load += new EventHandler (myLoadEvent);(myLoadEvent);
Web Part PropertiesWeb Part Properties Introduction Introduction
Web Parts have ‘properties’ that help the user Web Parts have ‘properties’ that help the user define their behaviordefine their behavior
Two kinds of properties:Two kinds of properties: Base class propertiesBase class properties Custom propertiesCustom properties
All properties must be serializable through All properties must be serializable through the XMLSerializerthe XMLSerializer
Property attributes define property behavior Property attributes define property behavior
Web Part Properties Web Part Properties (Contd.)(Contd.) Property attributes Property attributes
Browsable (.Net)Browsable (.Net)Category (.Net)Category (.Net)Description (.Net)Description (.Net) - Etc. - - Etc. -
FriendlyName (Web Part FriendlyName (Web Part Framework)Framework)HtmlDesigner (Web Part HtmlDesigner (Web Part Framework)Framework)WebPartStorage (Web Part WebPartStorage (Web Part Framework)Framework) - Etc. -- Etc. -
Web Part Properties Web Part Properties (Contd.)(Contd.) Saving PropertiesSaving Properties
Properties are serialized and stored in the Properties are serialized and stored in the databasedatabase
Stored in two contexts:Stored in two contexts: SharedShared PersonalPersonal
Storage is controlled by theStorage is controlled by the WebPartStorageWebPartStorage attribute:attribute: WebPartStorage =WebPartStorage = Storage.SharedStorage.Shared WebPartStorage =WebPartStorage = Storage.PersonalStorage.Personal WebPartStorage =WebPartStorage = Storage.NoneStorage.None
Creating a simple Creating a simple ‘Hello World’ Web Part, ‘Hello World’ Web Part, with a custom with a custom propertyproperty
Tool partsTool parts An IntroductionAn Introduction
Also derive from Web ControlsAlso derive from Web Controls and should be and should be used to add custom functionality to the tool used to add custom functionality to the tool panepane
Differ from web partsDiffer from web parts No mobilityNo mobility Limited base class property setLimited base class property set No property storageNo property storage Render only in the tool paneRender only in the tool pane
Rendering process similar to web parts Rendering process similar to web parts ToolPart.Render cannot be overriddenToolPart.Render cannot be overridden Implement RenderToolPartImplement RenderToolPart
Tool parts (Contd.)Tool parts (Contd.) Important MethodsImportant Methods
ToolPart.ApplyChanges()ToolPart.ApplyChanges() Called when the user clicks Apply/ Ok on Called when the user clicks Apply/ Ok on
the property sheetthe property sheet ToolPart.CancelChanges()ToolPart.CancelChanges()
Called when the user clicks Cancel on the Called when the user clicks Cancel on the property sheetproperty sheet
ToolPart.SyncChanges()ToolPart.SyncChanges() Called when the tool part needs to refresh Called when the tool part needs to refresh
itself. (example: after another tool part has itself. (example: after another tool part has saved properties)saved properties)
WebPart.GetToolPartsWebPart.GetToolParts Method on the web part base classMethod on the web part base class Used to associate tool parts with web partsUsed to associate tool parts with web parts
Creating a custom tool Creating a custom tool partpart
Part to part connectionsPart to part connections An IntroductionAn Introduction
Allows Web Parts to send & received Allows Web Parts to send & received basic types of data; e.g. Cell, Row, basic types of data; e.g. Cell, Row, List, etc.List, etc.
Uses standardized set of interfacesUses standardized set of interfaces Allows completely independent parts Allows completely independent parts
to connectto connect Enables end users to form Enables end users to form
connectionsconnections BrowserBrowser FrontPageFrontPage
My Web Part PageMy Web Part Page
Part to part connections Part to part connections (Contd.)(Contd.)
Part to part connections Part to part connections (Contd.)(Contd.) InterfacesInterfaces
ICellProvider, ICellConsumer ICellProvider, ICellConsumer IRowProvider, IRowConsumer IRowProvider, IRowConsumer IListProvider, IListConsumer IListProvider, IListConsumer IFilterProvider, IFilterConsumer IFilterProvider, IFilterConsumer IParametersOutProvider, IParametersOutProvider,
IParametersOutConsumerIParametersOutConsumer IParametersInProvider, IParametersInProvider,
IParametersInConsumerIParametersInConsumer