how can i write a style for hover for a button in c# in asp.net? i wrote this codes, but i don't know how to write for hover for it?
button1.Style[" border-style"] = "solid";
button1.Style["background-color"] = "#063a83";
button1.Style[" border-width"] = "3px";
button1.Style[" color"] = "White";
button1.Style[" font-family"] = "Tahoma";
button1.Style[" border-color"] = "Gray";
button1.Style[" border-radius"] = "10px";
button1.Style[" background-image"] = "url(../images/products/zoom2.png)";
button1.Style[" background-repeat"] = "no-repeat";
button1.Style[" padding"] = "10px";
button1.Style["Cursor"] = "pointer";
i want to write this for hover:
.btn:hover
{
background-color :#202020 ;
cursor:pointer;
}
this is my code:
Button button2 = new Button();
button2.Text = "buy";
button2.ID = ddr[2].ToString();
button2.Style[" border-style"] = "solid";
button2.Style["background-color"] = "#063a83";
button2.Style[" border-width"] = "3px";
button2.Style[" color"] = "White";
button2.Style[" font-family"] = "Tahoma";
button2.Style[" border-color"] = "Gray";
button2.Style[" border-radius"] = "10px";
button2.Style[" background-image"] = "url(../images/products/zoom2.png)";
button2.Style[" background-repeat"] = "no-repeat";
button2.Style[" padding"] = "10px";
button2.Style["Cursor"] = "pointer";
button2.Click += new System.EventHandler(detail_Click);
Panelproduct.Controls.Add(button2);
Add a CssClass
to you button like this:
Button button2 = new Button();
button2.Text = "buy";
button2.ID = ddr[2].ToString();
button2.CssClass = "btn"; //add a css class
button2.Click += new System.EventHandler(detail_Click);
Panelproduct.Controls.Add(button2);
Then in your css stylesheet add styles for that class, like so:
.btn{
border-style: solid;
background-color: #063a83;
/*more styles*/
}
.btn:hover{
background-color :#202020 ;
cursor:pointer;
}
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.