$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
How to Build Image Button using C#
Home > How to > Image Button
The PerButton from the ASP.NET AJAX SDK allows users to add an image to the button. Of course, if you want to add a background image to the button, this PerButton also offers related property setting APIs.
In following text, we will offer detailed C#.NET programming codes for users to create and customize image button in ASP.NET web application. Before running the sample C# codes listed below, in order to achieve the AJAX effect, please drag an AjaxPanel component from toolbox to aspx web page and then drag a button control from toolbox to that AjaxPanel. After you finish these preparing works, you can modify the button properties in the aspx.cs file.

ImageUrl

ImageUrl: by setting ImageUrl property to the location of the image that you are going to use, you can easily display an image on the button. This is the easiest way to add an image to the button.
PerButton1.Image.ImageUrl = "../../../Images/Button/Timer.jpg";

IsBackgroundImage

IsBackgroundImage: If you set this property to true, the defined image will be used as the background of the target button.
PerButton1.Image.IsBackgroundImage = true;

Event url

Event Url: If you want to show a different image on the button in specific situations, you can call following three events.
  • DisabledImageUrl: the image in current url will be displayed on the button when the PerButton control is disabled.
  • HoveredImageUrl: the image in the defined url will be showed when the mouse pointer is over the control.
  • PressedImageUrl: the image in the defined url will be showed when the button is pressed.
PerButton1.Image.DisabledImageUrl = "../../../Images/Button/Timer2.jpg";
PerButton1.Image.HoveredImageUrl = "../../../Images/Button/Timer3.jpg";
PerButton1.Image.PressedImageUrl = "../../../Images/Button/Timer4.jpg";
ASP.NET AJAX UI Controls