PC Review


Reply
Thread Tools Rate Thread

CSS - how to reference the CSS in a web page?

 
 
Dan Aldean
Guest
Posts: n/a
 
      26th Jan 2007
Hi,

I use ASP.NET 2.0 and I created a stylesheet, but I don't know how to make
it visible to a web form "MyWebPage.aspx" that uses the master page. I put a
reference to the css in the .master but it's not visible to the newly
created page. MyWebPage.aspx doesn't have a
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>structure.

Thanks


 
Reply With Quote
 
 
 
 
Dan Aldean
Guest
Posts: n/a
 
      26th Jan 2007
MyWebPage starts with something like:

<%@ Page language="c#" Inherits="MyWebPage" CodeFile="MyWebPage.aspx.cs"
MasterPageFile="Master.master" Title="This is my page"%>
<asp:Content ID="Content1" runat="Server"
but there is no <html> structure.

Should the code in master page which includes the reference :
<link rel="stylesheet" type="text/css" href="mystyle.css" />
be sufficient for MyWebPage to see the css document?


 
Reply With Quote
 
senfo
Guest
Posts: n/a
 
      27th Jan 2007
Dan Aldean wrote:
> Hi,
>
> I use ASP.NET 2.0 and I created a stylesheet, but I don't know how to make
> it visible to a web form "MyWebPage.aspx" that uses the master page. I put a
> reference to the css in the .master but it's not visible to the newly
> created page. MyWebPage.aspx doesn't have a
> <head>
> <link rel="stylesheet" type="text/css" href="mystyle.css" />
> </head>structure.


Use this, instead:

<style type="text/css" media="all">
@import "mystyle.css";
</style>

Afterwards, verify the rendered HTML to make certain that the path and
everything are what you want. You don't have to do anything fancy to
make CSS work in a master page.

--
Sean

website: http://senfo.blogspot.com
 
Reply With Quote
 
thersitz
Guest
Posts: n/a
 
      27th Jan 2007
hey Dan

I am using css in my masterpages in the format you have below and they work
just fine -- but then I am not using those style sheets on asp controls --
or atleast I haven't tried yet -- as I am new to aspNet -- tho I think it is
doable.

I'm just guessing here, but maybe it's yer doc type declaration that is
causing the problem or your html tag if you have xlmns attribute.

hey


"Dan Aldean" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
>
> I use ASP.NET 2.0 and I created a stylesheet, but I don't know how to make
> it visible to a web form "MyWebPage.aspx" that uses the master page. I put
> a reference to the css in the .master but it's not visible to the newly
> created page. MyWebPage.aspx doesn't have a
> <head>
> <link rel="stylesheet" type="text/css" href="mystyle.css" />
> </head>structure.
>
> Thanks
>



 
Reply With Quote
 
Dan Aldean
Guest
Posts: n/a
 
      27th Jan 2007
Thank you for the reply.
Can you tell m please how I can verify the rendered HTML? Is it thru View
Code?
Unfortunately I cannot check the solution in .NET 2.0 until monday, as I
have 1.0 at home.
Where exactly can I use the <style> as I do not see any <HTML> structure?

"senfo" <(E-Mail Removed)-WANT-NO-SPAM> wrote in message
news:%(E-Mail Removed)...
> Dan Aldean wrote:
>> Hi,
>>
>> I use ASP.NET 2.0 and I created a stylesheet, but I don't know how to
>> make it visible to a web form "MyWebPage.aspx" that uses the master page.
>> I put a reference to the css in the .master but it's not visible to the
>> newly created page. MyWebPage.aspx doesn't have a
>> <head>
>> <link rel="stylesheet" type="text/css" href="mystyle.css" />
>> </head>structure.

>
> Use this, instead:
>
> <style type="text/css" media="all">
> @import "mystyle.css";
> </style>
>
> Afterwards, verify the rendered HTML to make certain that the path and
> everything are what you want. You don't have to do anything fancy to make
> CSS work in a master page.
>
> --
> Sean
>
> website: http://senfo.blogspot.com



 
Reply With Quote
 
Dan Aldean
Guest
Posts: n/a
 
      27th Jan 2007
Thanks.
I need to use the css in the sever controls placed on the other form, not
the master.

"thersitz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hey Dan
>
> I am using css in my masterpages in the format you have below and they
> work just fine -- but then I am not using those style sheets on asp
> controls -- or atleast I haven't tried yet -- as I am new to aspNet --
> tho I think it is doable.
>
> I'm just guessing here, but maybe it's yer doc type declaration that is
> causing the problem or your html tag if you have xlmns attribute.
>
> hey
>



 
Reply With Quote
 
Dan Aldean
Guest
Posts: n/a
 
      27th Jan 2007
One more thing, it's not the master page that I need to use the css against,
it's a page that uses the master page that has some server controls which I
want to control from the style sheet


 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      27th Jan 2007
Among other things, master pages are designed to provide the overall
layout and design of an ASP.NET application at a single point (the
..master file) and reuse it in all content pages that derive from the
master. Once you've defined CSS in the master page you can reuse this
CSS across the entire site (and all controls in the content page
derived from the master).

On Jan 27, 1:51 am, "Dan Aldean" <doruro...@rogers.com> wrote:
> One more thing, it's not the master page that I need to use the css against,
> it's a page that uses the master page that has some server controls which I
> want to control from the style sheet


 
Reply With Quote
 
Dan Aldean
Guest
Posts: n/a
 
      27th Jan 2007
Thank you. In fact the master page is inherited by the other pages, isn't
it?
I tried this approach but for some reason it did not work.


 
Reply With Quote
 
Dan Aldean
Guest
Posts: n/a
 
      27th Jan 2007
But now another question pops into my mind: what do I do if I don't use a
master page?
Where do I use

<style type="text/css" media="all">
@import "mystyle.css";
</style>

immediately after

<%@ Page language="c#" Inherits="MyWebPage" CodeFile="MyWebPage.aspx.cs"
MasterPageFile="Master.master" Title="This is my page"%>

?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I turn off page reference in page break preview Nic_Qld Microsoft Excel Misc 2 3rd Jun 2009 07:17 PM
Page Reference referencing actual page # not what's in footer jennifer72401 Microsoft Word Document Management 7 27th Feb 2008 08:03 PM
automatically update a page # cross-reference when the page # chan =?Utf-8?B?bWFueg==?= Microsoft Word Document Management 1 25th May 2006 12:01 AM
Reference to another instance of page from a page (URGENT!!!) Oney Microsoft ASP .NET 2 27th Jan 2005 01:15 PM
HOW DO YOU GET A reference page to follow endnotes page? cbaird Microsoft Word New Users 1 26th May 2004 04:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:08 AM.