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
Creating & Deploying ASP.Net WebPart in MOSS 2007 Presented by Tarek Ghazali IT Technical Specialist Microsoft SQL Server MVP Microsoft SQL Server MCTS Web Development MCP Web Parts Overview • Web Parts is a framework built into ASP.NET 2.0 for building highly customizable portal-style pages. – Content designed to modular, consistent and easy to navigate – Web Parts add in support for customization and personalization Web Part History • Windows SharePoint Services 2.0 (WSS) – Designed with its own Web Part infrastructure – WSS serializes/stores/retrieves personalization data • ASP.NET 2.0 – – – – Designed with newer universal Web Part infrastructure Serializes/stores/retrieves personalization data More flexible and more extensible than WSS ASP.NET 2.0 does not support WSS v2 Web Parts • Windows SharePoint Services 3.0 (WSS) – Backward-compatible with v2 Web Parts – Offers a layer on top of the ASP.NET 2.0 Web Part infrastructure Web Part Types for WSS v3 ASP.NET 2.0 Runtime ASP WSS Web Web Parts Parts WSS v3 Runtime ASP Web Parts Hybrid Web Parts WSS v2 Runtime WSS Web Parts WSS Web Parts WSS v3 Web Part Page Structure SPWebPartManager SPWebPartZone (Left) SPWebPartZone (Right) Editor Zone Web Part 1 Web Part 3 Editor Part 1 Web Part 2 Web Part 4 Editor Part 2 Web Part 5 Catalog Zone Catalog Part 1 Catalog Part 2 Web Part - Example • The Web Part title bar contains the heading for the Web Part. – The Web Part title bar contains the heading for the Web Part. – The Web Part menu contains functions that enable you to minimize or close the Web Part, edit the Web Part, or get Help for a specific Web Part. – The body of the Web Part contains the content that you specified for the type of Web Part that is being used. In this example, the Web Part is an Image Web Part, which displays an image. Developing a WSS 3.0 Web Part • Web Parts derive from ASP.NET 2.0 WebPart base class using System; using System.Web.UI; using System.Web.UI.WebControls.WebParts; namespace MyWebParts { public class HelloWorldWebPart : WebPart { protected override void OnPreRender(EventArgs e) { this.Title = “Hello Web Part"; } protected override void RenderContents(HtmlTextWriter writer) { writer.Write("Hello, world"); } } } Deployment Steps • Deploy the .NET assembly – As private assembly in the \bin folder – As shared assembly in the Global Assembly Cache (GAC) • Register the Web Part as a safe control • Add the Web Part to the Web Part gallery available at the site collection level • Advertise the Web Part in the ‘Add Web Part’ dialog Web Part as a Safe Control • Web Parts usually run on Web Part Pages – Web Parts must be registered as Safe in web.config file – You must add entry to web.config before testing a Web Part <!– web.config in root directory of hosting virtual server --> <configuration> <SharePoint> <SafeControls> <SafeControl Assembly="AcmeWebParts" Namespace="AcmeWebParts" TypeName="*" Safe="True" /> </SafeControls> </SharePoint> </configuration> Manifest File • The application manifest is an XML file that: – Uniquely identifies the application – Describes dependencies on specific versions of sideby-side assemblies • http://msdn2.microsoft.com/enus/library/ms766454.aspx Manifest File (con.) <?xml version="1.0" encoding="utf-8" ?> <!-- You need only one manifest per CAB project for Web Part Deployment.--> <!-- This manifest file can have multiple assembly nodes.--> <WebPartManifest xmlns="http://schemas.microsoft.com/WebPart/v2/Manifest"> <Assemblies> <Assembly FileName="demo.dll"> <!-- Use the <ClassResource> tag to specify resources like image files or Microsoft JScript files that your Web Parts use. --> <!-- Note that you must use relative paths when specifying resource files. --> <ClassResources></ClassResources> <SafeControls> <SafeControl Namespace="DemoWebPart" TypeName="*" /> </SafeControls> </Assembly> </Assemblies> <DwpFiles> <DwpFile FileName="DemoWebPart.WebPart"/> </DwpFiles> </WebPartManifest> Demo Resources & Questions • Microsoft Resources: - msdn.microsoft.com/sqlserver/ - www.microsoft.com/sql/community • Contact me: - [email protected] • Download Presentation : - www.sqlmvp.com