Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a problem in my project.the problem is as:-
I make a Master page and in a div set a background image.After loading the master page on another form the image display but at run time Image is not displaying.
Plz give any solution for this.
Posted
Updated 23-Mar-11 20:30pm
v2
Comments
m@dhu 24-Mar-11 2:13am    
Not clear.
SURBHI TYAGI 24-Mar-11 2:16am    
i set the background of div by a image at master page but its not shown at run time.

This should work.
<div id="MasterContent" style="background:url(/Images/Image.jpg);">


using css is always a better option.
<script style="css">
{
.background { background:url(/Images/Image.jpg);}
}
<div id="MasterContent" class="background"></script>
 
Share this answer
 
U can create a folder as Image in your application now place your images in that in master page take an Image control in Div tag as u have taken.
Now set the properties of Image Control as per your choice but pay attention on ImageUrl property.
<asp:Image ID="Banner" Width="100%" Height="100px" runat="server" ImageUrl="~/image/your.jpg" />
 
Share this answer
 
To access the methods and properties of a master page from code in a content page, you can use the FindControl method:
Image imgOnMasterPage = (Image)
  (this.Master.FindControl ("ImageName"));
if(imgOnMasterPage != null)
{
//    Do as your wish
}
 
Share this answer
 
v2
Comments
Bhavna v 25-Mar-11 6:41am    
That is important one
If you are using the Image server control, or placing the images on your page through your code behind, you should reference the images using the "~/" syntax to refer to the application root. So if the image is in the root of your application's directory structure you could reference it through "~/logo.gif". If you had it stored in a folder called "images" you would use "~/images/logo.gif", etc.
 
Share this answer
 
Comments
SURBHI TYAGI 24-Mar-11 2:36am    
i set the image by style property.....thn this problem occur.by image server control it will display.

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