Hi,
I think that i can't get your question as you mean it sorry for that
but if do u want to change the background image of DIV and you have the images URL in your Database
so the best solution for me right now is to make the div run at server and start to set the style from the code behind
this is the ASPX page
<body>
<form id="form1" runat="server">
<div id="yu" runat="server"></div>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</form>
</body>
And this is the code of click event of the Button1
yu.Style.Add("background-image", "url('imgs/S(1).jpg')");
yu.DataBind();
you can change this
imgs/S(1).jpg with the Image URL you have in your Database
Another Way to set the background image with Javascript code
you can modify the function called changeDivImage to be able to change the image url dynamically by make it like this
<script language="javascript" type="text/javascript">
function changeDivImage(imgUrl) {
var imgPath = new String();
imgPath = document.getElementById("yu").style.backgroundImage;
document.getElementById("yu").style.backgroundImage = "url('" + imgUrl + "')";
}
</script>
then from the code behind you have to call the image URL you want like this to fire the javascript Function
string ImgPath = "the retrieved image URL from the Database";
ScriptManager.RegisterStartupScript(this, this.GetType(), "starScript", "changeDivImage('" + ImgPath + "');", true);
Regards,
Ahmed Mandour