Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Wednesday, July 30, 2014

Asp.net ImageButton control Example

Declare Asp.net Image Button control:

Declare ImageButton by fallowing code with property,As like Alternative text,
ImageUrl,Height,Width.Image Button is predefined Asp.net web control Use in web development. 

Asp.net ImageButton: 


<asp:ImageButton id="imagebutton1" runat="server"
           AlternateText="ImageButton 1"
           ImageAlign="left"
           ImageUrl="~/Images/Flower1.jpg"
           OnClick="ImageButton_Click" Height="148px" Width="274px"/>


Access  Asp.net ImageButton control useing javascript :

For Access ImageButton by javascript we  use fallowing code 
<script language="C#" runat="server">
      void ImageButton_Click(object sender, ImageClickEventArgs e) 
      {
         Label1.Text = "You clicked ImageButton control at the coordinates: (" + 
                       e.X.ToString() + ", " + e.Y.ToString() + ")";
      }
   </script>

By the JS code we get clicked position in Image.and print this on the Label Text.



Code of Asp.net Image Control:

<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>ImageButton Sample</title>
<script language="C#" runat="server">
      void ImageButton_Click(object sender, ImageClickEventArgs e) 
      {
         Label1.Text = "You clicked ImageButton control at the coordinates: (" + 
                       e.X.ToString() + ", " + e.Y.ToString() + ")";
      }
   </script>
</head>
<body style="height: 261px">
   <form id="form1" runat="server">
      <h3>ImageButton Example:</h3>
      Click Anywhere on the image.<br /><br />
      <asp:ImageButton id="imagebutton1" runat="server"
           AlternateText="ImageButton 1"
           ImageAlign="left"
           ImageUrl="~/Images/Flower1.jpg"
           OnClick="ImageButton_Click" Height="148px" Width="274px"/>
      <br />
      <br />
      <br />
      <asp:label id="Label1" runat="server"/>
      <br />
   </form>
</body>
</html>


Asp.net Programming ImageButton
Asp.net Programming ImageButton
Old Post :




Reference: