Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8897637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:23:53+00:00 2026-06-15T00:23:53+00:00

Why could I be unable to apply style on a nested page which is

  • 0

Why could I be unable to apply style on a nested page which is using a master page? I am just trying to apply simple some back-color to body and some div in an individual page.

My (nested)page Reservations.aspx has this code

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" 
AutoEventWireup="true" CodeFile="Reservations.aspx.cs" Inherits="Reservations" %>
<asp:Content runat="server" ContentPlaceHolderID="HeadContent">
    <link href="~/Styles/input.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div class="mainDiv">
........
</div></asp:Content>

input.cs has this code

body { background-color:Silver; }
.mainDiv { background-color:Blue; }

Site.Master has this code

<head runat="server">
<asp:ContentPlaceHolder ID="HeadContent" runat="server"></asp:ContentPlaceHolder>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /></head>
<body>.........

I can get Silver Color as background of Reservations.aspx only if I apply this to master page which I do not want. I have not been able to get helped from accepted answer of This question and tutorials.

Edit

using <link.. before or after might make some difference, thanks for info but it is not doing anything in this case. I have tested it both ways after my problem was solved.

Guidance to ResolveUrl solved my problem, because I tried using pickurl in visual-studio 2010 instead of typing manually and got this url Styles/input.css instead of ~/Styles/input.css.

Update => How it was Solved

href="Styles/Site.css" or href='<%= ResolveUrl("~/Styles/Site.css")%>'

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:23:54+00:00Added an answer on June 15, 2026 at 12:23 am

    You need to use resolve url as follows.

    <%= ResolveUrl("~/")%>
    

    as follows

    <link href='<%= ResolveUrl("~/Styles/Site.css")%>'  rel="stylesheet" type="text/css" />
    

    Working when your Master Page and Content Page are on the same folder then any include in the master page will work.

    But when your Master Page and Content Page are in different folder it will not find the same style sheet or java-script file because files are not in the same folder.

    So Resolve Url resolve the URL on the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been unable to find any info on this, which seems like it could
I am trying to apply some conditional formatting on a WPF DataGrid.The requirement is
Could anyone guide me in created a simple app in JS? What the app
Could someone please suggest why this is happening... I’ve got some code to pretty
I'm using some images as banners on my site. They're full (960px) width and
I'm using the code below to render a preview of a PDF page. However
Could someone please explain why I'm getting the error: java.lang.RuntimeException: Unable to start activity
I've just purchased Xcode 4 and am trying to develop my apps in it.
I'm trying to run a some .jnlp applications (games) on latest os-x. While doing
I have developed a module 'newpatient' which I am unable to install through a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.