tags:

views:

41

answers:

2

I am Displaying all the images from database to image tag no ai have problem in after seleting one image that image should be apply as background. What is javascript for writting this? thank you....

A: 

Where is the problem?

Сергій
Please use the "Add Comment" option for this kind of question - only use "Add Answer" if you actually have an answer - Thanks.
Sohnee
A: 

To set a background image using JavaScript, you could do this:

document.getElementById("myElement").style.backgroundImage = "myimage.png";

But if you are using asp.net MVC, you could set a snippet of CSS, or the style of the element in the view instead, which would remove the need to use JavaScript. For example...

<div style='background-image: url(<%= Model.MyImage %>);'>
Sohnee