hi! ;)

I just want to asked on how I can set the image as background.

I put an image on the working station but once I run it, it doesn't appear on the browser. thanks.

I'm using Visual Studio 2008 ;)

Hi!

I presume that your image is stored inside Images folder under root of your web-app.

Code your web-page

<head runat="server">
  <style type="text/css">
       .sample
        {
          background:url(Images/image1.jpg);
         }
  </style>
</head>

<body>
  <div class="sample">
      <h1>Sample Text</h1>
  </div>
</body>

hello sir :)

thank you for your reply :D

but the image is still not appearing in the browser.

here's the code that I made.

<html>
<head runat="server">
    <style type="text/css">
        .sample
        {
        	background:url(~/App_Data/s2.jpg);
        	}
    </style>
    <title>Lupon</title>
</head>
<body>

    <form id="form1" runat="server">
    <div class="sample">
    </div>

    </form>
</body>

Do not place images inside the special folder like App_Data, App_code etc. Create a folder named Images under your root and move all image files into it.

I presume following structure,

Webapp/
      |----------------\Images
      |                  |s2.jpg
      |sample.aspx
<html>
<head runat="server">
    <style type="text/css">
        .sample
        {
        	background:url(Images/s2.jpg);
                height:300px;
                width:300px;
          }
    </style>
    <title>Lupon</title>
</head>
<body>

    <form id="form1" runat="server">
    <div class="sample">
         
    </div>

    </form>
</body>

Thank you very very very very mucchh sir :)

it works :)

very much thank you. :)

now I can move to the next project :)

thank you sir :)

God bless :)

thanks! :D

Thanks! kgenn. All the best.

how to put background image to full screen without repeating or tiling of a image?

Member Avatar

Use cover.

commented: Good answer in any war zone. +12