简体   繁体   中英

How to add ssclass to a dynamically created button in asp.net?

I am Creating a Button Dynamically in Asp.net how can i add existing css style to the dynamic button i want to change the button color on Mouse hover and Mouse focus i tried in so many ways like:

Button btn1 = new Button();              
btn1.CssClass = "btnmbl1";
btn1.Attributes.Add("href", "../Styles/style.css");
btn1.Attributes["CssClass"] = "btnmbl1";
//btn1.Attributes.Add("CssClass", "btnmbl1");
btn1.Attributes.Add("type", "text/css");
btn1.Attributes.Add("rel", "btnmbl1");

but no luck plz help me Thank u

Assign class name to to CssClass property.

btn1.CssClass = "btnmbl1";

or use class instead of CssClass in Add method

btn1.Attributes.Add("class", "btnmbl1");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM