Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Actually i am having two master pages. and i am developing a web application in that i want to add image to the background of the two master pages
 
//bellow i am giving login master-page code.
 
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="main.master.cs" Inherits="School_Apps.main" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>School Apps</title>
<asp:ContentPlaceHolder ID="head" runat="server">

<style type="text/css">
.style1
{
width: 250px;
}
.style2
{
width: 980px;
}
.style3
{
width: 958px;
}
</style>
</head>
<body>
<form id="form1" runat="server">



style="background-color: white;"
class="style2">
<%----%>



style="border: 1px solid #000000">
<asp:Label ID="lblWelcome" runat="server" Font-Bold="True" Font-Size="medium"
ForeColor="#990000" Text="Welcome ">
<asp:Label ID="lblWelcomeUser" runat="server" Font-Bold="True" Font-Size="Small"
ForeColor="#990000" Text="...">
 |
<asp:LinkButton ID="lbtnLogout" runat="server" Font-Bold="true"
Font-Size="Medium" ForeColor="#3333CC" onclick="lbtnLogout_Click">Logout

style="border: 1px solid #000000" class="style1">


style="border: 1px solid #000000" class="style1">




    
<asp:ImageButton ID="imgbtnEnguiryForm" runat="server" Height="44px"
Width="161px" onclick="imgbtnEnguiryForm_Click"
ImageUrl="~/images/imk.jpg" />




    
<asp:ImageButton ID="imgbtnAdmission" runat="server" Height="44px"
Width="161px" ImageUrl="~/images/add.jpg" />




    
<asp:ImageButton ID="imgbtnFeeCollection" runat="server" Height="44px"
Width="161px" ImageUrl="~/images/cel.jpg" />




    
<asp:ImageButton ID="imgbtnReports" runat="server" Height="44px"
Width="161px" ImageUrl="~/images/rep.jpg" />




    
<asp:ImageButton ID="imgbtnClassRoom" runat="server" Height="44px"
Width="161px" ImageUrl="~/images/class.jpg" />




    
<asp:ImageButton ID="imgbtnSMSPlugin" runat="server" Height="44px"
Width="161px" ImageUrl="~/images/Sms.jpg" />




    
<asp:ImageButton ID="imgbtnLeads" runat="server" Height="44px" Width="161px"
ImageUrl="~/images/leads.jpg" />




    
<asp:ImageButton ID="imgbtnCallenderEvent" runat="server" Height="44px"
Width="161px" ImageUrl="~/images/cal.jpg" />






<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">



style="border-style: solid none none none; border-width: thin"
bgcolor="white">
<asp:Label ID="lblFooter" runat="server" Text=""
Font-Bold="true" ForeColor="#EFCEFF">
</form>
</body>
</html>
Posted 4-Feb-13 18:02pm
ntitish1.4K
Edited 4-Feb-13 18:05pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

first upload image to your website....goto->properties->background you can choose background property your image...try it once.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Other wise
 
goto masterpage design press F4 choose background import image
  Permalink  
Comments
ntitish at 5-Feb-13 0:28am
   
i am not having that option in my properties window..........i am using 2008 visual studio ...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
Its Very Simple
ctrl+shift+a Add new item
select Stylesheet
 
add below code to your style sheet
body
{
    background-image: url('../Images/forrest_guitar_2-wallpaper-2400x1350.jpg');
}
 
give reference of style sheet in master page
<link href="CSS/StyleSheet.css" rel="stylesheet" type="text/css" />
  Permalink  
Comments
ntitish at 5-Feb-13 0:38am
   
sir you are saying to take new page....for this background image.. i am not getting properly...
sunil_mali at 9-Feb-13 1:12am
   
Yes add new page stylesheet and copy
body element as it is to your stylesheet
and then in your master page add link attribute in your head section
i mean to say inside your head tag... you just,try it seriously its very easy .... just for you i did this and posted in such easy way.....
 
ntitish at 11-Feb-13 0:42am
   
thanks sir...
sunil_mali at 11-Feb-13 1:23am
   
Please mark it as answer if you are ok with it...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

In the MasterPage.master page add the below code into the <head></head> region
<link href="Style.css" rel="stylesheet" type="text/css" /><pre lang="CSS">
Then create a .Css file with the name "Style.css" and drop it into the folder where the masterpage is.
In the Style.css add the below line
body
{
    background-image: url('image.jpg');
}
 
If you do have any doubts please let us know.
  Permalink  
Comments
ntitish at 5-Feb-13 1:10am
   
//i am confused to apply where and where...if u dont mind can u guide me...
//below is my code.
 
<head runat="server">
<title>School Apps</title>
<asp:ContentPlaceHolder ID="head" runat="server">

<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.style1
{
width: 250px;
}
.style2
{
width: 980px;
}
.style3
{
width: 958px;
}
body
{
background-image:url('~/images/testing.jpeg');
}
</style>
</head>
<body>
<form id="form1" runat="server">
 

//in this the form code is there which i posted under the question
 
</form>
</body>
joe_j at 5-Feb-13 1:22am
   
sure not a problem. is the above code inside your masterpage?
ntitish at 5-Feb-13 2:01am
   
yes sir....
joe_j at 5-Feb-13 2:06am
   
ok, then if you are trying with the above code, you do not need to put this <link href="style.css" rel="stylesheet" type="text/css" /> as you have already specifying the CSS within your masterpage itself <style type="text/css">.....</style>
So first take off the <link href=...../> part
Then check if the image file "testing.jpeg" actually exists and is in the "images" folder.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

<style>
body
{
    background-image: url('image.jpg');
}
</style>
 
put this inside your style of your page
and also keep some good image in images folder with same name
  Permalink  
Comments
ntitish at 5-Feb-13 2:35am
   
ok i got it thanks....
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

<body>
 
<center>
              <table width="1024">
              <tr><td width="100%">
                  <asp:Panel ID="Panel1" runat="server" Width="100%" Height="150px"
                      BackImageUrl="~/Images/front2.jpg">
                  </asp:Panel>
              </td></tr>
        </table>
</body>
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 403
1 Sergey Alexandrovich Kryukov 227
2 Richard Deeming 180
3 ChauhanAjay 170
4 Snehasish_Nandy 161
0 Sergey Alexandrovich Kryukov 6,367
1 OriginalGriff 5,588
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100