This article gives readers a way to automatically get a stylesheet for all pages based on the motherboard, which is the support for relative path adjustment provided by the control. You can use this in a master page to easily reference a reusable item throughout the project. A CSS style sheet file, regardless of whether the item is relative to the root directory or a child application.
A technique to use in ASP.net 2.0 is to recommend that when using CSS, use the features of the motherboard page to provide a unified UI for your site, use a master page to refer to all the stylesheets in one place, and all pages based on this master page will automatically get these stylesheets.
One technique available is the support for relative path tuning provided by the
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" %>
<title>Master Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<form id="form1" runat="server">
<asp:contentplaceholder id="MainContent" runat="server">
</asp:contentplaceholder>
</form></body> The pages on your site can then be similar to the following, which automatically gets style sheet settings at run time and in the HTML WYSIWYG (WYSIWYG) Designer at design time vs:
<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Sample Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<a href="/Products">Click here to go to the Products section (note the absolute path) </a>
</asp:Content> Because it's contained in. A picture reference in a CSS style sheet file is relative to the. The path to the CSS file is referenced by the browser, rather than the path to the page using the stylesheet file, this behavior can be combined with the
The picture referenced in this way is also correctly displayed in the HTML WYSIWYG (WYSIWYG) Designer of VS 2005, and if not, VS 2005 sometimes has difficulty deciding to get the "/" root path of a picture reference.