Skip Navigation LinksASP.Net 2.0 Training : ASP.Net ImageButton
Banner for ASP.Net 2.0 training classes in Visual Basic 2005 

Skip Navigation Links
Visit my other site:

certification training

Free Flash tutorials and training

Free Dreamweaver Video Tutorials

Free PHP Training

Visual Basic Windows Training




If you like this site please link to it


ImageButton

  • The ImageButton control is used to display a clickable image.

Property

Description

CausesValidation

By default, a page is validated when a Button control is clicked. To prevent a page from being validated when clicking on a Button control, set this property to "false"

id

A unique id for the control

ImageUrl

The URL of the image to display

OnClick

The name of the function to be executed when the image is clicked

runat

Specifies that the control is a server control.  Must be set to "server"

  • Open Visual Studio
  • Add a new webform
  • Name it imageButton.aspx
  • Click the Add button
  • Select the Design View
  • Add an ImageButton control to the webform
  • Name it smallImage1
  • Repeat it 3 more times, naming it smallImage2, smallImage3, smallImage4
  • Add 4 images to your site
  • Select the ellipsis in the ImageURL property and select the image in each imageButton

  • Using the cursor change the size of the imageButtons down to a small button

  • Add an Image control and name it bigImage

  • Double click the imageButton and add this code:

bigImage.ImageUrl = sender.imageURL
We are going to use the same subroutine for each imagebutton
So instead of using smallimage1.imageURL we use the imageURL of the sending object. That way it does not matter which imageButton is clicked, that image will get put into the image control

  • Scroll down to the code for the first imageButton and you will see the following code added:

  • copy this code into each of the other imageButton controls

  • test it

Another feature you may want to add:

  • Select the image control
  • Change the height and width properties to 300 each

This will keep the image size steady



      ASP.Net 2.0 tutorials & training