|
Image
The Image Web server control is used to display an image on a Web page. To set
the image to be displayed for this control we use the ImageUrl property.
The class hierarchy for this control is as follows:
Object
Control
WebControl
Image
Look at the sample at the bottom of this page for a demo.
ImageButton Control
The ImageButton Web server control is used to display images and responds to mouse
clicks on the image. The class hierarchy for this control is as follows:
Object
Control
WebControl
Image
ImageButton
To set the Image for this control we use the ImageUrl property.
Image buttons support both Click and Command events. When we handle Click events,
we are passed the actual location of the mouse in the image. We can use Command event
handlers to make the image button work like a command button.
Sample
Drag a Label and an ImageButton Control on to the form and paste the following code:
Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As _
System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Label1.Text = "You clicked the image button at" & e.X & " " & e.Y
End Sub
|
When you run the code and click on the image button, the X and Y coordinates are displayed
on the label.
Live Code Demo
Image Control
ImageButton Control
|