ASP.NET - css is not support - Asked By msakt on 09-Apr-12 04:56 AM

 css is not work when will include in master page  from ouside folder.......if work when write inline code inside masterpage
Somesh Yadav replied to msakt on 09-Apr-12 05:09 AM


<link href="~/Stylesheet1.css" rel="Stylesheet1" type="text/css" />

Tilde (~) represent root directory.

If this doesn't work, if you can show us your directory structure, and look at the rendered source we can help more.

Jitendra Faye replied to msakt on 09-Apr-12 05:24 AM
This is because of path/ location problem.

put master page and css in same path/location and try. then it will work.

try and let me know.
dipa ahuja replied to msakt on 09-Apr-12 07:01 AM
Hi.. You can create css file in  and even you can use here a better concept that is themes.
A theme is contain two types of file 1. css and 2. skin . You can choose css by using the cssClass property and Skin for SkidID
To add css file is easy. Just Add new item->Css file
add some classes to the css file. You can even write the css class without creating new file, and inside the
<style type="text/css">
► applying css file is also easy just by the
for html control
<div class="div1">
for server control
<asp:Image ID="Image3" CssClass="imgBig" runat="server" ImageUrl="~/1.bmp" />
► Using SkinFile
You can implement thems by adding new .skin file in your website:
1. Add one skin file in your website:
2. It will ask you to add in App_Themes folder say yes
3. Add the code in your skin file
Just for beginning add the code :
<asp:button runat="server" BackColor="lightblue" ForeColor="black" />
And save it. Now in you webpage in Page Directive add the Theme property = skinfile ex:
<%@ Page Theme="SkinFile" Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs"Inherits="Default5" %>
Add one button in your webpage. And Run the page. You will get the effect of button as you have provided in the theme file
► Apply skin from code behind
protected void page_PreInit(object sender, EventArgs e)
    Page.Theme = "SkinFile";
Also with skin file you can add a css similar to it which you can access from everypage