Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to apply background image behind each images which is generated dynamically.
please help me.


XML
for (int i = 0; i < s.Length; i++)
                                {
                                    image1 += @" <a href='../Upload/Testimonial/" + s[i] + "' target='_blank' rel='prettyPhoto'><div style='width:100px; height:100px; padding:4px; background-image: url(../images/burnt.jpg);'><img  runat='server' width='85px' height='80px' id='" + s[i] + "' src='../Upload/Testimonial/" + s[i] + "' /></a></div>";

                                }
                                image += @"<div class='gallery clearfix' style='float:left; width:100%;margin:15px 10px 10px 10px' clear='both'><div style='width:90%; margin:10px;padding:8px;background:#E5E4E2;border-radius: 9px;'><h3>" + Convert.ToString(ds1.Tables[0].Rows[co]["Author"]) + "</b></h3><br/>" + Convert.ToString(ds1.Tables[0].Rows[co]["Descr"]) + "</div><div class='gallery clearfix' style='width:100%; background-image: url(../images/burnt.jpg); height:100px; padding:8px; border-bottom:2px dashed #19354B;'>" + image1 + "</div></div><br/>";
                                image1 = "";
Posted
Comments
Dholakiya Ankit 14-Sep-13 3:28am    
well this is unclear you want to bind one image to all images or diff for all?
Mohd Arif Khan 14-Sep-13 3:32am    
one image for all
Mohd Arif Khan 14-Sep-13 3:33am    
if i'm putting an extra div between <img> and anchor tag all controls are scattered.
Dholakiya Ankit 14-Sep-13 3:34am    
check my solution
Mohd Arif Khan 14-Sep-13 3:45am    
i have tried earlier with inline css. but is not working

1 solution

HTML
<img class="backgroundclass" />



and in css
CSS
.backgroundclass

{
background-image:url(path to image);
// you can also add extra attributes to adjust then image of background
}


this will sortout your issue

:)

[updated]

XML
<pre lang="CSS">
.backgroundclass

{
background-image:url(path to image);
height:200px;
width:200px;
// you can also add extra attributes to adjust then image of background
}</pre>
 
Share this answer
 
v3
Comments
Mohd Arif Khan 14-Sep-13 3:39am    
it's not working, and how to define width and height of background image
Dholakiya Ankit 14-Sep-13 4:12am    
see updated
Dholakiya Ankit 14-Sep-13 4:13am    
or user background-size
Mohd Arif Khan 14-Sep-13 7:04am    
Thanks a ton :)
Dholakiya Ankit 14-Sep-13 7:13am    
got solution?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900