Here is my code that i used to display an image in the background , but it is repeating and tiling . How do i do it in code behind to set the image to non-tiling ? i never use CSS to display the background image :
protected void Image_Selection_Change(object sender, EventArgs e)
{
//PageBody.Attributes["bgColor"] = System.Drawing.Color.FromName(DropDownList1.SelectedItem.Value).Name;
if (DropDownList1.SelectedItem.Text == "Ant and the Grasshopper")
{
PageBody.Attributes.Add("style", "background:url(images/ant-and-grasshopper.jpg);");
PageBody.Attributes.Add("body", "background-repeat: no-repeat");
Session["Background"] = "background:url(images/ant-and-grasshopper.jpg);";
ImageButton9.Visible = false;
ImageButton11.Visible = true;
}
if (DropDownList1.SelectedItem.Text == "Food Fit for the King")
{
PageBody.Attributes.Add("style", "background:no-repeat,background:url(images/King.jpg);");
Session["Background"] = "background:url(images/King.jpg);";
ImageButton11.Visible = false;
ImageButton9.Visible = true;
}
}
i tried the background-repeat: no repeat but to no avail . Thanks in advance.
"background:no-repeat,background:url(images/King.jpg);"
Ought to be
"background: url(images/King.jpg) no-repeat;"
Unless commas are treated specially, the comma between the two background attributes doesn't separate them. Only a semi-colon does that. Also, having two background attributes causes them to conflict.
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.