这是我用来在背景中显示图像的代码,但它是重复和平铺的。我如何在后面的代码中将图像设置为非平铺?我从不使用 CSS 来显示背景图片:
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;
}
}
我尝试了 background-repeat: no repeat 但无济于事。提前致谢。