Successfully reported this slideshow.

Parallelminds.web partdemo

852 views

Published on

This is demo silde for Web Parts using asp.net.

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

Parallelminds.web partdemo

  1. 1. Manisha M. Chothe<br />Junior Solution Developer <br />Parallel Minds Technology Solutions Pvt. Ltd. <br />www.parallelminds.biz<br />(o) + 91-20-65000209 <br />http://manishachothe.blogspot.com/<br />Google: mchothe8@gmail.com<br />|<br />
  2. 2. Agenda<br />1 Introduction<br />2.     Before webpart<br />3.     Need of webpart<br />4.     Web part benefits<br />5.     Dev environment required for web parts<br />6.     Web part infrastructure<br />7.     Hello world web part<br />8.     Getting property from editor zone<br />9.     Calling web service from web part<br />10.     Showcase Data grid in web part<br />11.   Using ajax in webpart<br />12.   Using user control in web part<br />13.   Best coding practices for web part<br />
  3. 3. Web Parts in asp.net<br />
  4. 4. What is Web Part???<br />
  5. 5. Introduction<br />A Web Part is a .NET Web custom control assembly that uses a Web Part description file (.dwp). <br />The .dwp file contains XML metadata that describes an instance of the Web Part.<br />Web Parts is a framework built into ASP.NET 2.0 for building highly customizable portal-style pages. <br />
  6. 6. Introduction<br />ASP.NET Web parts is an integrated set of controls for creating Web sites that enable end users to modify the content, appearance, and behavior of Web pages directly from a browser.<br />End users can customize Web Parts pages by changing the page layout, adding and removing Web Parts, editing Web Parts properties, establishing connections between Web Parts, and more. <br />
  7. 7. Before Web Parts…..<br />Before ASP.NET 2.0, developer had to build his own custom personalization framework to implement personalization feature in the application.<br />Web Parts are included in ASP.NET server control framework and are used like any other ASP.NET server controls. <br />
  8. 8. Building Web Parts<br />There are two basic ways to create a Web Part.<br /> You can treat any standard Microsoft ASP.NET control as a Web Part or <br />you can build a custom control that derives from the base WebPart class.You are not required to modify a control in any way to use it as a Web Part. Standard ASP.NET controls (such as the Calendar and GridView controls), Web User Controls, and even custom controls can all be used as Web Parts. <br />
  9. 9. One of the simplest ways to use controls is through the Visual Studio development environment. The Toolbox area within Visual Studio (when developing Web Forms) includes a Web Parts category that contains the various controls available to utilize Web Parts in an application.<br />
  10. 10. ASP.NET 2.0 Web Part page<br />
  11. 11. ASP.NET Web Parts Life Cycle<br />
  12. 12. InitializationThe WebPartZone objects register with the WebPartManager control.The WebPartManager control loads the static WebPart objects.The WebPartManager control calls the TrackViewState method for each static WebPart object already in the control hierarchy at this point.<br />Initialization CompleteThe WebPartManager control loads the dynamic WebPart objects and the WebPartConnection objects. <br />The WebPartManager control calls the WebPartPersonalization control on the static and dynamic WebPart objects.<br />
  13. 13. Load CompleteThe WebPartManager control activates the WebPartConnection objects.<br />Save State Complete<br />The WebPartManager control saves the static and dynamic WebPart objects' personalization information in permanent storage.<br />
  14. 14. ASP.NET 2.0 Web Part infrastructure<br />
  15. 15. Advantages of Web Parts<br />Web Parts allows for personalization of page content. They allows users to move or hide the Web Parts and add new Web Parts changing the page layout.<br />Web Parts allows user to export or import Web Parts settings for use in other pages. Web Parts retain the properties, appearance and the data across the pages when imported or exported.<br />Web Parts can be assigned role-based access. So you can determine which Web Parts can share by all or which should be hidden for certain roles. This helps us to provide customized content based on security.<br />Web Parts can talk to each other. You can utilize the data in one Web Part in another Web Part for different purposes.<br />
  16. 16. Web Parts Modes<br />a) Normal mode: End user cannot edit or move sections of page.<br />b) Edit Mode: End user can edit Web Parts on the page including Web Parts title, color or even setting custom properties.<br />c) Design Mode: End user can rearrange the order of the pages Web Parts in a WebPartZone.<br />d) Catalog Mode: End user enjoys the choice to add new Web Parts or add deleted Web Parts in any WebPartZone on the page.<br />
  17. 17. WebPartManager<br />The WebPartManager is the manager for all web parts. If you use webparts in your web projects you are required to use the WebPartManager. Usually you just drag and drop this into your webform and are ready to go.<br />WebPart Zones<br />There are four kinds of zones in web part zones:<br />Web Part Zone<br />Editor Zone<br />Catalog Zone<br />Connection Zone<br />WebPart Zone<br />The web part Zone is the basic unit for web parts. By placing different contents in a web part zone we can allow a user to drag and drop contents on a page.<br />
  18. 18. Catalog Zone<br />The purpose of the CatalogZone control is to allow end users to customize Web Parts pages by adding Web Parts to them. <br />for example, to enable users to restore closed Web Parts to the page by including a CatalogZone in the page.<br />A Catalog Zone can contain several types of Catalog Part controls. The following list summarizes the Catalog Part controls provided with the Web Parts control set:<br />PageCatalogPart<br />DeclarativeCatalogPart<br />ImportCatalogPart<br />
  19. 19. EditorZone<br /> The EditorZone Web Server control serves as the primary control in the Web Parts control set for hosting EditorPart controls on a Web page.<br />AppearanceEditorPart:-<br /> Lets users customize the visual properties of a WebPart control at run time, such as the width, height, and title.<br />BehaviorEditorPart:-<br /> Lets users customize behavior properties of a WebPart control at run time, such as displaying minimize, close, and edit buttons.<br />
  20. 20. LayoutEditorPart:-<br /> Lets users customize layout properties of a WebPart control at run time, such as selecting a minimized or normal state, or setting the index at which the control will appear within the target zone.<br />PropertyGridEditorPart:-<br /> Lets users edit custom properties at run time that are declared as part of a WebPart control.<br />
  21. 21. Following is the list of features provided exclusively by the SharePoint WebPart class:<br />Cross page connections<br />Connections between Web Parts that are outside of a Web Part zone<br />Client-side connections (Web Part Page Services Component)<br />A data caching infrastructure that allows caching to the content database<br />
  22. 22. User Control Vs Web Parts<br />User Control<br />User Controls cannot be shared across web applications but they can be created using a designer tool.<br />Customization and personalization is not possible using User Controls.<br /> Web Part<br />Web Part is a combination of User Control and Custom Control.<br />Web Parts are ASP.NET controls in that they add extra dimensions of user customization and personalization.<br />
  23. 23. Simple Hello World Example for Web Parts<br />Visual studio ->create web Site ->asp.net web site ->ok<br />
  24. 24.
  25. 25.
  26. 26.
  27. 27. Use of User Control in Web Part<br />
  28. 28. Use of User Control in Web Part<br />Solution Explorer -> Right click on project -> Add ->New item ->select web user control -> Add<br />
  29. 29.
  30. 30.
  31. 31.
  32. 32.
  33. 33.
  34. 34. Getting Property From Editor Zone<br />
  35. 35.
  36. 36.
  37. 37.
  38. 38.
  39. 39.
  40. 40.
  41. 41.
  42. 42. The code will populate the DropDownList with all the available modes for the WebParts. <br /> private void BindData()<br /> {<br />WebPartDisplayModeCollection modes = wpm.DisplayModes;<br />foreach (WebPartDisplayMode mode in modes)<br /> {<br />ddlModes.Items.Add(mode.Name); <br /> }<br />ddlModes.DataBind(); <br /> }<br />
  43. 43. Now, in order to select the particular mode you need to catch the Selected_IndexChanged event of the DropDownList. <br />protected void ddlModes_SelectedIndexChanged(object sender, EventArgs e)<br />{<br />WebPartDisplayMode mode = (WebPartDisplayMode) wpm.SupportedDisplayModes[ddlModes.SelectedValue];<br />wpm.DisplayMode = mode; <br />}<br />
  44. 44. Showcase of Gridview in Web Part<br />
  45. 45.
  46. 46.
  47. 47. Calling Web Service From Web Parts<br />
  48. 48. Create web site-> asp.net web service-> ok<br />
  49. 49.
  50. 50.
  51. 51.
  52. 52.
  53. 53.
  54. 54. Use of Ajax in web Parts<br />
  55. 55.
  56. 56.
  57. 57.
  58. 58.
  59. 59.
  60. 60.
  61. 61. Connection Zone<br /> The ConnectionsZone Web server control provides a user interface (UI) that enables users to form connections between WebPart and other server controls that reside in WebPartZoneBasezones.<br /> You can connect controls in these ways:<br />Declare a connection in a Web page.<br />Create a connection in code.<br />Add a ConnectionsZone control to the page so that users can connect the controls on demand.<br />
  62. 62.
  63. 63.
  64. 64. Thank You!<br />

×