WORKING WITH ZONES in VS .NET

Encode Data Matrix 2d barcode in VS .NET WORKING WITH ZONES

WORKING WITH ZONES
Paint Data Matrix In .NET Framework
Using Barcode creator for ASP.NET Control to generate, create Data Matrix ECC200 image in ASP.NET applications.
www.OnBarcode.com
Generating UPC - 13 In VS .NET
Using Barcode creation for ASP.NET Control to generate, create EAN-13 Supplement 5 image in ASP.NET applications.
www.OnBarcode.com
Customizing chrome At times we ll want to create a custom look for the outer area of our zones a look that will give all our pages a distinctive feel or flair. To do so, we create our own custom chrome class and write code within that class that performs custom rendering logic to suits our needs. To allow us to use custom chrome in the portal, each zone has a method that is responsible for returning the chrome type that should be used for rendering its parts. The methods for each of these three zones that return their chrome are WebPartZoneBase.CreateWebPartChrome EditorZoneBase.CreateEditorPartChrome CatalogZoneBase.CreateCatalogPartChrome Overriding these methods provides us with an interception point we can use to return our own chrome classes which contain custom rendering logic for rendering parts and their contents. To see how this works, take a look at listing 5.5 and notice the logic contained within its RenderPartContents and RenderWebPart methods:
Making QR Code ISO/IEC18004 In VS .NET
Using Barcode printer for ASP.NET Control to generate, create QR Code JIS X 0510 image in ASP.NET applications.
www.OnBarcode.com
Print PDF 417 In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create PDF417 image in ASP.NET applications.
www.OnBarcode.com
Listing 5.5 This custom chrome class uses its RenderWebPart and RenderPartContents methods to display the user interface of web parts for a web zone.
USS Code 39 Maker In VS .NET
Using Barcode generation for ASP.NET Control to generate, create Code 3 of 9 image in ASP.NET applications.
www.OnBarcode.com
Printing USS-128 In VS .NET
Using Barcode maker for ASP.NET Control to generate, create GS1 128 image in ASP.NET applications.
www.OnBarcode.com
public class CustomWebPartChrome : WebPartChrome { public CustomWebPartChrome(WebPartZone zone, WebPartManager wpm) : base(zone, wpm) { } public override void RenderWebPart( HtmlTextWriter writer, WebPart webPart ) {
Matrix Barcode Creator In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create Matrix Barcode image in ASP.NET applications.
www.OnBarcode.com
UPC Case Code Generation In .NET
Using Barcode maker for ASP.NET Control to generate, create DUN - 14 image in ASP.NET applications.
www.OnBarcode.com
Render outer area of web part
Drawing ECC200 In None
Using Barcode creator for Software Control to generate, create Data Matrix 2d barcode image in Software applications.
www.OnBarcode.com
Data Matrix 2d Barcode Drawer In .NET
Using Barcode drawer for ASP.NET Control to generate, create Data Matrix ECC200 image in ASP.NET applications.
www.OnBarcode.com
writer.Write("Outer section of the web part"); writer.WriteBreak(); this.RenderPartContents(writer, webPart); writer.WriteBreak(); writer.Write("End of outer section"); } protected override void RenderPartContents( HtmlTextWriter writer, WebPart webPart ) { writer.Write("Part contents"); } }
Barcode Generation In Java
Using Barcode maker for Android Control to generate, create Barcode image in Android applications.
www.OnBarcode.com
Barcode Scanner In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Render web part content
PDF 417 Maker In None
Using Barcode generator for Office Excel Control to generate, create PDF 417 image in Excel applications.
www.OnBarcode.com
UCC - 12 Creation In Java
Using Barcode creator for Android Control to generate, create UCC - 12 image in Android applications.
www.OnBarcode.com
USING WEBPARTCHROME
Draw PDF417 In .NET Framework
Using Barcode creator for Reporting Service Control to generate, create PDF417 image in Reporting Service applications.
www.OnBarcode.com
Creating PDF-417 2d Barcode In None
Using Barcode encoder for Font Control to generate, create PDF417 image in Font applications.
www.OnBarcode.com
This custom chrome class shown in the preceding segment inherits from WebPartChrome and can therefore be returned as the chrome to be used by the CreateWebPartChrome method of a WebPartZone. In order for the chrome to be used by a zone, we must associate the chrome with the zone. In the case of a WebPartZone, we accomplish this by overriding the CreateWebPartChrome method and returning an instance of our custom chrome class. The following snippet shows a custom WebPartZone using our CustomWebPartChrome to perform web part rendering:
Scan QR-Code In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Encode UPC-A Supplement 5 In .NET Framework
Using Barcode maker for Reporting Service Control to generate, create UPC A image in Reporting Service applications.
www.OnBarcode.com
public class CustomWebPartZone : WebPartZone { protected override WebPartChrome CreateWebPartChrome() { return new CustomWebPartChrome(this, this.WebPartManager); } }
Decode Barcode In C#.NET
Using Barcode scanner for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Decoding UPC - 13 In VB.NET
Using Barcode scanner for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
At runtime when the zone is rendering its body section, it will loop through each of its contained web parts and actually use the chrome to do the rendering of that part like so:
WebPartChrome chrome = this.WebPartChrome; foreach (WebPart part in this.WebParts) { chrome.RenderWebPart( writer, part ) ; }
This final snippet shows us that every web part within the WebPart zone is rendered through the chrome, and not through the zone itself. 5.4.3 Viewing the results of custom chrome To appreciate the additional level of control gained over the rendering process by creating our custom chrome, we can now use the CustomWebPartZone to host some web parts and view the rendered output. Add the following markup to a page in your test project and run it to view the output.
<wp:CustomWebPartZone ID="CustomWebPartZone1" runat="server"> <ZoneTemplate> <asp:TextBox ID="part1" runat="server" Title="Part One" /> <asp:TextBox ID="part2" runat="server" Title="Part Two" /> </ZoneTemplate> </wp:CustomWebPartZone>
Here our CustomWebPartZone class is declared within a page, and as we can see, it contains two web parts declared within its zone template. At runtime the RenderWebPart method of our custom chrome class will be called twice once for each web part contained within the zone. Figure 5.7 shows the results of the page being run in a browser. As we see, the text rendered from the RenderWebPart and RenderWebPartContents methods is displayed instead of the textbox web parts we d normally expect
WORKING WITH ZONES
Figure 5.7 This figure shows how the RenderWebPart and RenderWebPartContents methods affect the rendered output of web parts contained within a zone.
to see. To further highlight what s going on, we can remove the overridden RenderWebPart method we added to the custom chrome class. Removing this method from our custom chrome class means that the base class implementation of that method will be called at runtime and do all of its normal rendering of borders, titles and verbs so at least our parts will look like the web parts we ve seen in the past. Our custom RenderWebPartContents code will still run and render the body of the part as the text that we emitted: Part Contents. Figure 5.8 shows the output rendered when we remove the implementation we added for the RenderWebPart method. Working through the chapter to this point has provided a good look at the three main rendering methods for zones and we ve seen how the level of control from the combination of styles, zone rendering, and chrome rendering simplifies the task of creating the exact look and feel we want for parts within our portal. We ve also seen that each of these three methods of affecting the rendered output comes with a different level of difficulty. Using styles is relatively straightfor- Figure 5.8 By removing the code we wrote ward, while overriding the rendered sections within zones is for the RenderWebPart much more difficult because then we are attempting to create method, we make the web parts regain their a lot of visual elements and functionality. familiar look as the Now that we ve learned about the makeup of zones and verbs and title texts seen how to affect their visual elements, it s time to take a are also rendered in closer look within the EditorZone and the CatalogZone. the header area.
Copyright © OnBarcode.com . All rights reserved.