asp:ImageButton control
ImageButton control is utilized to post the shape or fire an occasion either customer side or server side. Its like an asp:Button control, the main contrast is, you have capacity to put your own particular picture as a catch.
ImageButton control is for the most part used to post the frame or fire an occasion either customer side or server side. When it is rendered on the page, by and large it is actualized 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 and so on are executed through style properites of <input> tag. You can set its Image area either by setting ImageURL properties in the .aspx page or from server side page. (different properties can likewise be set from the two 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 |
Example -
// 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" />
0 comments:
Post a Comment