tags:

views:

19

answers:

1

I need to put a new CSS from ASP.NET when the image button Control comes dynamically

+1  A: 

What exactly do you mean "imag[e] butt[o]n Control comes dynamically"?

You can add css to individual controls from code-behind via Attributes property, e.g.:

ImageButton1.Attributes.Add("style", "height:30px");

You can add a whole stylesheet to a page, e.g.:

System.Web.UI.HtmlControls.HtmlLink myHtmlLink = new System.Web.UI.HtmlControls.HtmlLink();
myHtmlLink.Href = "/css/my.css";
myHtmlLink.Attributes.Add("rel", "stylesheet");
myHtmlLink.Attributes.Add("type", "text/css");

Or you can do it via javascript, jQuery example:

$('img.myImage').attr('style', 'height:30px');
Shagglez
I put some buttons dynamically and I want to also refer to css class at the same time
mnaftal
If you already have a class defined in css, you can add that class via CssClass property, like ImageButton1.CssClass = "myclass"
Shagglez