Reputation: 17
Quick question. I am dynamically creating some buttons and basically want to add a background image to them in the code behind. Can someone tell me how its supposed to look like? I want to use the Button.Style.Add().
I tried Button.Style.Add("background-image","url(~/Uploads/Steak.jpg)"); but it did not work.
Upvotes: 0
Views: 78
Reputation: 86
string strimgpath = "Uploads/Steak.jpg";
String strImgLocation = "url('" + strimgpath + "')";
idimage.Style.Add("background-image", strImgLocation);
Upvotes: 0
Reputation: 135
please use following code:
Button.Style.Add("background-image","url('~/Uploads/Steak.jpg')");
Add single quotes to the url
Upvotes: 1