The Verbs property is used to associate custom verbs with a web part. in .NET framework

Creating Data Matrix ECC200 in .NET framework The Verbs property is used to associate custom verbs with a web part.

Listing 2.8 The Verbs property is used to associate custom verbs with a web part.
Data Matrix Encoder In .NET
Using Barcode encoder for ASP.NET Control to generate, create Data Matrix ECC200 image in ASP.NET applications.
www.OnBarcode.com
Print Barcode In .NET Framework
Using Barcode maker for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
WebPartVerbCollection IWebActionable.Verbs { get { WebPartVerb timeVerb = new WebPartVerb( "TimeVerb1", new WebPartEventHandler(DisplayTime) ); timeVerb.Text = "Change Display Text"; timeVerb.ImageUrl = "~/images/event.gif"; WebPartVerb clearVerb = new WebPartVerb( "ClearVerb1", new WebPartEventHandler(ClearTime) ); clearVerb.Text = "Clear Display Text";
DataMatrix Printer In VS .NET
Using Barcode generator for ASP.NET Control to generate, create DataMatrix image in ASP.NET applications.
www.OnBarcode.com
Encode Linear 1D Barcode In VS .NET
Using Barcode creation for ASP.NET Control to generate, create Linear 1D Barcode image in ASP.NET applications.
www.OnBarcode.com
Create verbs using the WebPartVerb class
Encoding Barcode In .NET
Using Barcode creator for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Making EAN 13 In .NET
Using Barcode creation for ASP.NET Control to generate, create EAN 13 image in ASP.NET applications.
www.OnBarcode.com
Associate any text and images to display for the verb
EAN / UCC - 13 Generation In VS .NET
Using Barcode creator for ASP.NET Control to generate, create EAN / UCC - 13 image in ASP.NET applications.
www.OnBarcode.com
DUN - 14 Generator In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create UPC Shipping Container Symbol ITF-14 image in ASP.NET applications.
www.OnBarcode.com
return new WebPartVerbCollection( new WebPartVerb[] { timeVerb, clearVerb } ); } }
Data Matrix Drawer In Visual Basic .NET
Using Barcode encoder for VS .NET Control to generate, create Data Matrix image in .NET framework applications.
www.OnBarcode.com
ECC200 Encoder In None
Using Barcode encoder for Software Control to generate, create ECC200 image in Software applications.
www.OnBarcode.com
Add the verbs to a collection and return them
Data Matrix Reader In None
Using Barcode decoder for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
UPC - 13 Reader In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
UNDERSTANDING WEB PART INTERNALS
Decode Barcode In Visual C#.NET
Using Barcode Control SDK for Visual Studio .NET Control to generate, create, read, scan barcode image in .NET framework applications.
www.OnBarcode.com
Decoding Barcode In Java
Using Barcode Control SDK for Eclipse BIRT Control to generate, create, read, scan barcode image in BIRT applications.
www.OnBarcode.com
Figure 2.9 Our custom web part verbs appear in the web part s menu along with any existing zone verbs.
Draw QR Code 2d Barcode In .NET
Using Barcode creation for Reporting Service Control to generate, create Denso QR Bar Code image in Reporting Service applications.
www.OnBarcode.com
Code 128 Code Set B Encoder In Visual Basic .NET
Using Barcode drawer for .NET Control to generate, create Code-128 image in Visual Studio .NET applications.
www.OnBarcode.com
The verbs are created and their attributes set. This includes setting the ImageUrl and assigning the text that will be displayed to the user. Finally, the verbs are added to a WebPartVerbCollection and returned to the portal framework where they are then added to the web part for display. When the web part is run in a browser, we can see that our custom verbs are added to the verb list along with any zone verbs. Clicking on either of our custom verbs causes the web page to post back to the web server where the associated handler method will be called. A nice enhancement might be to actually disable the Clear Display Text verb if the text has already been cleared from the display. The WebPartEventHandler delegate We saw that the WebPartVerb class is used to create verbs. When the WebPartVerb class was constructed, two pieces of information were passed as its arguments. This is shown in the following snippet of code:
Painting UPC-A Supplement 2 In Visual C#.NET
Using Barcode drawer for .NET framework Control to generate, create GTIN - 12 image in VS .NET applications.
www.OnBarcode.com
Barcode Printer In .NET Framework
Using Barcode creation for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
WebPartVerb clearVerb = new WebPartVerb( "ClearVerb1", new WebPartEventHandler(ClearTime) );
Encode Denso QR Bar Code In Objective-C
Using Barcode printer for iPhone Control to generate, create QR-Code image in iPhone applications.
www.OnBarcode.com
Draw ANSI/AIM Code 39 In None
Using Barcode drawer for Microsoft Word Control to generate, create Code 39 Extended image in Microsoft Word applications.
www.OnBarcode.com
The first argument specifies what ID to use for the verb control, and the second argument is a WebPartEventHandler delegate. The WebPartEventHandler delegate is used to associate a method with the click event for the verb, and enforces that the specified method implements the WebPartEventHandler interface.
NOTE
A delegate is a special Type in .NET that allows us to specify that methods which handle events must implement a specific interface.
When the verb that we ve created is clicked by a user, a postback occurs and a method named ClearTime is called to handle the click event. The following piece of code shows the code for the ClearTime method:
protected void ClearTime(object sender, WebPartEventArgs e) { this.lblText.Text = string.Empty; }
WEB PARTS: THE BUILDING BLOCKS OF PORTALS
Note that the ClearTime method implements the WebPartEventHandler by taking an object and an instance of the WebPartEventArgs class as its arguments. Handling events in the browser In addition to handing the click events for verbs on the server, the WebPartVerb class also provides a way to specify that a client-side event handler is used. Specifying a client-side event handler for verbs allows us to handle the click event for the verb in the browser, and means that there is no postback to the web server, so no page refresh occurs. To use client-side event handlers we can simply specify the name of the client-side function when creating the verb. This process is almost identical to the previous process when we used a server-side event handler, except that the name of the handling method is passed into the verb s constructor as a string literal instead of being passed as an instance of the WebPartEventHandler class. Listings 2.9 and 2.10 display the code for a Verbs property, which adds a verb that is handled by a client-side JavaScript function named ClientClickHandler. You can see that the ID of the control is passed to the function.
Listing 2.9 Verbs can also be associated with client-side event handlers that do not require the item to post back to the web server.
WebPartVerbCollection IWebActionable.Verbs { get { WebPartVerb verb = new WebPartVerb( "Verb1", "ClientClickHandler('" + this.ClientID + "')" ); verb.Text = "Display Web Part ID"; verb.ImageUrl = "~/images/event.gif"; return new WebPartVerbCollection(new WebPartVerb[] {verb}); } }
Listing 2.10 A client-side JavaScript function is written to handle the verb s click event in the browser
<script language="javascript" type="text/javascript"> function ClientClickHandler(webPartID) { alert( "You clicked the following web part: " + webPartID + "." ) ; } </script>
Copyright © OnBarcode.com . All rights reserved.