How to generate image button dynamically in ASP.NET with C# Example | How to give tooltip and css class to image button in ASP.NET with C#

Image button is one of the good feature of ASP.NET. Here I have given a sample code for the image button. Here i have included property set up as well.. Please go through example.  In this, i have explained how to give tool tip, CSS class, image url, onclick event, height, width and how to add this dynamic image button to the form.




protected void Page_Load(object sender, EventArgs e)
    {
        ImageButton imgBtn;
        imgBtn = new ImageButton();
        imgBtn.Attributes.Add("onclick", "javascript:return false;");
        imgBtn.ImageUrl = "~/sample.jpg";
        imgBtn.ID = "img_Tooltip";
        imgBtn.ToolTip = "www.aspnettutorialonline.blogspot.com";
        imgBtn.CssClass = "img_tooltip_Style";
        imgBtn.Height = 50;
        imgBtn.Width = 100;
        form1.Controls.Add(imgBtn);
    }

Output:


generate image button dynamically in ASP.NET with C# Example
generate image button dynamically in ASP.NET with C# Example
If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar