Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > CSS - how to reference the CSS in a web page?

Reply
Thread Tools

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

 
 
Dan Aldean
Guest
Posts: n/a
 
      01-26-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
 
      01-26-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
 
      01-27-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
 
      01-27-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
 
      01-27-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
 
      01-27-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
 
      01-27-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
 
      01-27-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" <(E-Mail Removed)> 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
 
      01-27-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
 
      01-27-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

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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Web reference - Reference.cs cannot be updated ToTo ASP .Net Web Services 1 12-04-2006 07:50 PM
reference.vb missing after web reference update cypress phill ASP .Net Web Services 0 03-29-2006 09:10 AM
ASP.NET 2.0: master pages and web user controls: reference to a non-shared member requires an object reference bminder ASP .Net 0 06-24-2005 12:22 AM
web reference interfering with reference to component Dude ASP .Net 0 11-09-2004 11:53 AM



Advertisments