Set a background image on a webpage when using the homepage

Is it possible to set a background image on a web page when the web page is based on the home page. Please note that this is not the background of the main page that I want to change, but the background of the page on which the main page is used.

+2


source to share


4 answers


You can just add a style rule for the {} body or whatever in a real ASPX page. It will override any style set at the master page level.

edit: example:



<%@ Page Title="Example" Language="C#" MasterPageFile="~/MasterPages/Main.master" 
    AutoEventWireup="true" CodeBehind="TroubleShootScanning.aspx.cs" 
    Inherits="SpectrumTechnologies.TroubleShootingScanning" %>

<asp:Content ID="Content1" ContentPlaceHolderID="mainContent" runat="server">
    <style type='text/css'>
        body { background-image: url(images/bgimage.jpg); }
    </style>
    <!-- the rest of the page here -->
</asp:Content>

      

This will override any values โ€‹โ€‹set in the style sheet.

+4


source


You can put a content placeholder on the master page that sits inside the header.



Then on the content page, place a content control where you can directly include the second modified CSS or STYLE block.

+2


source


I suggest adding the tag <asp:ContentPlaceHolder ID="ExtraStyles" runat="server" />

to your homepage header. This way you can add the following to your page:

<asp:Content ID="ExtraStylesContent" ContentPLaceHolderId="ExtraStyles" runat="server">
  <style type="text/css">
  body {background-image:url('someotherimage.jpg');
  </style>
</asp:Content>

      

By adding an extra ContentPlaceHolder you won't get scattered style tags, they will end up in the main tag of the rendered html.

+2


source


There is an extra trick to add to this ... (Second line below) The background show also helps when testing locally.

+1


source







All Articles