In this web programming tutorial we will learn that how we can create an image button dynamically in asp.net using c#. see the below code and put it in your .cs file in page load event.
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.web-healer.blogspot.com";
imgBtn.CssClass = "img_tooltip_Style";
imgBtn.Height = 50;
imgBtn.Width = 100;
form1.Controls.Add(imgBtn);
}
Tags:
asp.net