What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 10232 |  Welcome, Guest!   Register  Login
Home > Tutorials > ASP.NET Tutorials > Image Button

Silverlight Tutorials | Report a Bug in the Tutorial
Found interesting? Add this to:


asp:ImageButton control
ImageButton control is used to post the form or fire an event either client side or server side. Its like a asp:Button control, the only difference is, you have ability to place your own image as a button.
 
ImageButton control is generally used to post the form or fire an event either client side or server side. When it is rendered on the page, generally it is implemented through <input type=image > HTML tag.

There is no UserSubmitBehavior property like Button control with LinkButton control.

Its properties like BackColor, ForeColor, BorderColor, BorderStyle, BorderWidth, Height etc. are implemented through style properites of <input> tag. You can set its Image location either by setting ImageURL properties in the .aspx page or from server side page. (other properties can also be set from both pages)

Following are some important properties that are very useful.
ImageUrl Gets or Sets the location of the image to display.
CausesValidation Value can be set as true/false. This indicates whether validation should be performed when a button is clicked.
PostBackUrl Indicates the URL on which the Form will be posted back.
ValidationGroup Gets or Sets the name of the validation group that the button belongs to. This is used to validate only a set of Form controls with a Button.
OnClick Attach a server side method that will fire when button will be clicked.
OnClientClick Attach a client side (javascript) method that will fire when button will be clicked.
DEMO : Button Show Source Code
  Ex. Example of Label Control
                        // with OnClick event
                        <asp:ImageButton ID="ImageButton1" runat="Server" ImageUrl="~/images/demoButton.gif" OnClick="ActivateServerSideEvent" />
                        
                        // With OnClientClick and CommandName
                        <asp:ImageButton ID="ImageButton2" runat="Server" ImageUrl="~/images/demoButton.gif" OnClientClick="GiveAlertToUser()" CommandName="ClientSideButton" />
                        
                        // With OnClick and ValidationGroup
                        <asp:ImageButton ID="ImageButton3" runat="Server" OnClick="FireServerSideEvent" ImageUrl="~/images/demoButton.gif" ValidationGroup="demo" />
                    





About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 5:48:29 AM