Lesson 1: Exploring Specialized Web Server Controls in .NET framework

Print QR Code 2d barcode in .NET framework Lesson 1: Exploring Specialized Web Server Controls

Lesson 1: Exploring Specialized Web Server Controls
Generate QR-Code In Visual Studio .NET
Using Barcode generator for ASP.NET Control to generate, create QR Code 2d barcode image in ASP.NET applications.
www.OnBarcode.com
Barcode Creator In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create barcode image in ASP.NET applications.
www.OnBarcode.com
'VB Partial Class Image_Control Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Image1.ImageUrl = "~/Images/Girl.gif" Image1.DescriptionUrl = "~/ImageDescription.htm" Image1.AlternateText = "This is a picture of a girl" End Sub End Class //C# using using using using using using using using using using
Generating QR Code JIS X 0510 In C#.NET
Using Barcode generator for .NET Control to generate, create QR image in Visual Studio .NET applications.
www.OnBarcode.com
Print Quick Response Code In Visual Studio .NET
Using Barcode maker for VS .NET Control to generate, create QR Code image in .NET framework applications.
www.OnBarcode.com
System;
Printing QR Code ISO/IEC18004 In Visual Basic .NET
Using Barcode drawer for .NET framework Control to generate, create QR Code ISO/IEC18004 image in .NET framework applications.
www.OnBarcode.com
PDF-417 2d Barcode Printer In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create PDF 417 image in ASP.NET applications.
www.OnBarcode.com
System.Data;
Matrix 2D Barcode Generator In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create Matrix Barcode image in ASP.NET applications.
www.OnBarcode.com
Paint Linear Barcode In VS .NET
Using Barcode maker for ASP.NET Control to generate, create 1D Barcode image in ASP.NET applications.
www.OnBarcode.com
System.Configuration;
DataMatrix Drawer In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create Data Matrix image in ASP.NET applications.
www.OnBarcode.com
Drawing EAN / UCC - 13 In .NET Framework
Using Barcode drawer for ASP.NET Control to generate, create EAN13 image in ASP.NET applications.
www.OnBarcode.com
System.Collections;
Drawing QR Code 2d Barcode In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create Quick Response Code image in ASP.NET applications.
www.OnBarcode.com
Identcode Creator In .NET
Using Barcode maker for ASP.NET Control to generate, create Identcode image in ASP.NET applications.
www.OnBarcode.com
System.Web;
EAN-13 Printer In VS .NET
Using Barcode creation for Reporting Service Control to generate, create GS1 - 13 image in Reporting Service applications.
www.OnBarcode.com
Data Matrix ECC200 Creator In C#
Using Barcode encoder for VS .NET Control to generate, create Data Matrix image in .NET applications.
www.OnBarcode.com
System.Web.Security;
Recognizing Barcode In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Painting USS Code 128 In None
Using Barcode maker for Excel Control to generate, create Code 128 Code Set A image in Office Excel applications.
www.OnBarcode.com
System.Web.UI;
Print EAN-13 In Objective-C
Using Barcode maker for iPhone Control to generate, create GS1 - 13 image in iPhone applications.
www.OnBarcode.com
Paint Code 39 In Java
Using Barcode maker for Java Control to generate, create Code-39 image in Java applications.
www.OnBarcode.com
System.Web.UI.WebControls;
Printing QR Code In .NET Framework
Using Barcode drawer for Reporting Service Control to generate, create Denso QR Bar Code image in Reporting Service applications.
www.OnBarcode.com
UPC-A Recognizer In Visual C#
Using Barcode scanner for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
System.Web.UI.WebControls.WebParts;
System.Web.UI.HtmlControls;
public partial class Image_Control : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e) { Image1.ImageUrl = "~/Images/Girl.gif";
Image1.DescriptionUrl = "~/ImageDescription.htm";
Image1.AlternateText = "This is a picture of a girl";
This code is simply setting properties. The tilde (~) indicates the current Web appli cation folder. Figure 3-6 shows the rendered Web page, including the alternate text, which is displayed as a ToolTip.
Figure 3-6
The rendered Image control displaying the AlternateText property as a ToolTip.
3
Exploring Specialized Server Controls
The ImageButton Control
The ImageButton control is used to display a clickable image on a Web page that can be used to post back to the Web server when the image is clicked. This control gener ates an <input type="image"> element when rendering to HTML. The ImageButton con trol inherits directly from the Image control class, as shown in Figure 3-7.
WebControl Class Control
ImageButton Class Image Properties
Image Class WebControl
CausesValidation CommandArgument CommandName Enabled GenerateEmptyAlternateText OnClientClick PostBackUrl TagKey Text ValidationGroup Methods AddAttributesToRender GetPostBackOptions ImageButton LoadPostData OnClick OnCommand OnPreRender RaisePostBackEvent RaisePostDataChangeEvent Events Click Command System.Web.UI.WebControls.IButtonControl.Click
IPostBackDataHandler IPostBackEventHandler IButtonControl
Figure 3-7
The ImageButton control hierarchy.
Like the Image control, the ImageButton control s primary property, ImageUrl, indi cates the path to an image that can be downloaded from the browser and displayed. This property maps directly to the src attribute of the <input> element in HTML. Because the ImageButton inherits from the Image control, it also contains the AlternateText, DescriptionUrl, ImageAlign, and GenerateEmptyAlternateText properties. The ImageButton control has a Click and Command event that functions like the Button control. The second argument of the Click event has a data type of ImageClickEvent
Lesson 1: Exploring Specialized Web Server Controls
Args, which lets you retrieve the x- and y-coordinates of the user s click. The ImageButton control is represented as the <asp:ImageButton> element in source view and has no content, so you can write this element as a singleton element. Here s another example: A Web page was created and an ImageButton control was added to the page. This control also uses the same image file called Girl.gif and HTML page called ImageDescription.htm that were used in the previous Image control exam ple. The following code was added to the code-behind page to show how the ImageButton control s properties can be set programmatically and the Click event can be implemented.
'VB Partial Class ImageButton_Control Inherits System.Web.UI.Page Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click ImageButton1.AlternateText = _ String.Format("Button Clicked at {0},{1}", e.X, e.Y) End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ImageButton1.ImageUrl = "~/Images/Girl.gif" ImageButton1.DescriptionUrl = "~/ImageDescription.htm" ImageButton1.AlternateText = "This is a picture of a girl" End Sub End Class //C# using using using using using using using using using using
System;
System.Data;
System.Configuration;
System.Collections;
System.Web;
System.Web.Security;
System.Web.UI;
System.Web.UI.WebControls;
System.Web.UI.WebControls.WebParts;
System.Web.UI.HtmlControls;
public partial class ImageButton_Control : System.Web.UI.Page
{ protected void Page_Load(object sender, EventArgs e) { ImageButton1.ImageUrl = "~/Images/Girl.gif";
ImageButton1.DescriptionUrl = "~/ImageDescription.htm";
ImageButton1.AlternateText = "This is a picture of a girl";
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
3
Exploring Specialized Server Controls
ImageButton1.AlternateText =
string.Format("Button Clicked at {0},{1}", e.X, e.Y);
This code sets the ImageButton control properties in the Page_Load event handler. In the ImageButton1_Click event handler, the x- and y-coordinates are retrieved and placed into the AlternateText property, as shown in Figure 3-8.
Figure 3-8 The rendered ImageButton displaying the AlternateText message after the ImageButton was clicked.
The ImageMap Control
The ImageMap control is used to display a clickable image on a Web page that can be used to post back to the Web server when the image is clicked. This control differs from the ImageButton control in that the ImageMap control allows you to define regions or hot spots that cause PostBack, whereas clicking anywhere on the ImageButton causes PostBack. This control generates an <img usemap="#myMap"> element. In addition, a <map name="myMap"> element with nested <area> elements is also cre ated when rendering to HTML. The ImageMap control inherits directly from the Image control class, as shown in Figure 3-9. Like the Image control, the ImageMap control s primary property, ImageUrl, indicates the path to the image that can be downloaded from the browser and displayed. This property maps directly to the src attribute of the <img> element in HTML. Since the ImageMap inherits from the Image control, it also contains the AlternateText, DescriptionUrl, ImageAlign, and GenerateEmptyAlternateText properties.
Copyright © OnBarcode.com . All rights reserved.