ImageButton Example in ASP.NET using C#

ImageButton Example in ASP.NET using C#


Posted in : ASP.Net Posted on : November 23, 2010 at 5:17 PM Comments : [ 0 ]

In this article we will introduce with ImageButton control in ASP.NET using C#.

ImageButton Example in ASP.NET using C#

ImageButton control in ASP.NET is just like a Button control. The ImageButton control is used to display a clickable image. Events of ImageButton are the same as Button control. You will provide the image using ImageUrl property of the ImageButton control. In this example we use the ImageButton when we click on this ImageButton the result will be displayed in label.

ImageButton.aspx (Design page):

ImageButton.aspx (source code):


		<%@
		Page
		Title=""
		Language="C#"
		MasterPageFile="~/RoseindiaMaster.master"
		
		
		AutoEventWireup="true"
		CodeFile="ImageButton.aspx.cs"
		Inherits="ImageButton" 
		%>
		
		<asp:Content
		ID="Content1"
		
		ContentPlaceHolderID="head"
		Runat="Server">
		</asp:Content>
		<asp:Content
		ID="Content2"
		
		ContentPlaceHolderID="ContentPlaceHolder1"
		Runat="Server">
		<div>
		<h2
		style="color:Green">ImageButton 
		in ASP.NET 4 , C#</h2>
		
		<p
		style="color:Green">
		
		<asp:ImageButton
		ID="ImageButton1"
		runat="server"
		
		ImageUrl="~/Images/ProgrammingTutorial.gif"
		onclick="ImageButton1_Click"/>
		
		</p>
		
		<br
		/>
		
		<asp:Label
		ID="Label1"
		runat="server"
		Font-Bold="True"
		ForeColor="#000099"
		
		style="font-size: 
		xx-large"></asp:Label>
		</div>
		</asp:Content>
		

ImageButton.aspx.cs (C# code file):


		using System;
		
		using 
		System.Collections.Generic;
		
		using System.Linq;
		
		using System.Web;
		
		using System.Web.UI;
		
		using System.Web.UI.WebControls;
		
		public 
		partial
		class
		ImageButton 
		: System.Web.UI.Page
		
		{
		protected
		void 
		Page_Load(object 
		sender, EventArgs 
		e)
		{
		
		protected
		void 
		ImageButton1_Click(object 
		sender, 
		ImageClickEventArgs e)
		{
		Label1.Text = 
		"This is devmanuals.com";
		}
		}
		

Output:

Download source code
Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics