Working with CSS style sheets in vs 2005 and ASP.net 2.0

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.