How to use image button in asp.net

{0 Comments}

To use image button is not so tough task this is just easy as other controls, but little thing more have to be done while using this. If you are going to use image button first time then please download button image or some thing like that because you have to use them while using image button. So let’s start……

  • First drag drop or just double click on image button option in the tool bar menu, by doing this an image button will be automatically added to the web page(aspx)
  • Now it will look like some color full error icon type of image that means that a image is not added to you image button. So have an image in your image button. Firstly create a image folder. Or you can simply put it in the root of your project.
  • Then select your image button then right click on it the select the proper ties option from the floating option appearing right to your cursor, after then in properties window select the image url option add navigate you your image and define a path.
  • Now image you have added to your root or the image folder will now start appearing exactly it appears.
  • Now to add a click event handler to the associative image button, just double click on the same button which will create a event handler event in the code behind page.
  • Now right you piece of code which you want s to do after the image button click. You can modify and attach much more properties according to your need from the properties windows.

 HTML |  copy code |? 
1
<asp:ImageButton ID="ImageButton1" runat="server" 
2
            ImageUrl="~/imageUI/Rectangular_Preview_P.png" onclick="ImageButton1_Click" />

code behind(c#)

 C# |  copy code |? 
1
 protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
2
    {
3
 
4
    }

Leave a Comment

Your email address will not be published.