Click here to Skip to main content
15,847,653 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi Sir,

Please help me on setting the background image on my application.
The background image is not displaying, the image and my application are in the same directory but still not displaying. Here's my code below. Thank you in advance.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Logon.aspx.cs" Inherits="Logon" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
<style type="text/css">
    <title>My Test Log-In Page</title>
    <form id="form1" runat="server">
   <font face="Verdana">Logon Page</font>
      <td><input id="txtUserName" type="text" runat="server"/></td>
      <td><ASP:RequiredFieldValidator ControlToValidate="txtUserName"
           Display="Static" ErrorMessage="*" runat="server"
           ID="vUserName" /></td>
      <td><input id="txtUserPass" type="password" runat="server"/></td>
      <td><ASP:RequiredFieldValidator ControlToValidate="txtUserPass"
          Display="Static" ErrorMessage="*" runat="server"
          ID="vUserPass" />
      <td>Persistent Cookie:</td>
      <td><ASP:CheckBox id="chkPersistCookie" runat="server" autopostback="false" /></td>
                <asp:Button ID="cmdLogIn" runat="server" onclick="cmdLogIn_Click"
                    Text="Log-In" />
<asp:Label id="lblMsg" ForeColor="red" Font-Name="Verdana" Font-Size="10" runat="server" />
Silver Lightning 7-Mar-11 3:51am    
Still no answer, please help me on this sir. Thanks
That's Aragon 7-Mar-11 3:52am    
It should be displayed. Make sure that image name and extension are correct.
Silver Lightning 7-Mar-11 4:11am    
yes sir it is correct, in fact, it was displaying in design view, but when I'm running the application, it is not displaying. please help me sir. thanks
That's Aragon 7-Mar-11 4:50am    
Just check the view source of the page and check the path of the image. It should be displayed. If not then there must be some issue in the path/image name. You can use FireBug(for firefox) or google chrome(press ctrl + shift + j to view developer tool) for better diagnosis.

Hey guys,

Try removing the quotes in your stylesheet :

should be

Share this answer
Silver Lightning 7-Mar-11 4:37am    
Hi Sir Eduard,

Still not displaying while application is running, but in design view it shows.
it was displaying in design view, but when I'm running the application, it is not displaying.
It is clearly the relative path issue.

Your statement background-image:url('gtbackground.jpg'); is not working. Image is not present at desired location at runtime.

Start with putting the image one level up/down from the location and see. Once you get the relative path correctly for runtime display set it accordingly.
Share this answer
Silver Lightning 7-Mar-11 4:43am    
I already did that sir, but still not displaying. What do you think should I revise? Thanks
Sandeep Mewara 7-Mar-11 4:48am    
Try setting the image url at runtime.

Use this tip for reference:

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