Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Dynamically adding a stylesheet

Reply
Thread Tools

Dynamically adding a stylesheet

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      05-08-2006
I want to dynamically add a stylesheet using <style type="text/css"></style>
tags. The code that will use this stylesheet will be shared, so I will not
have control over what the user does as far as stuff like adding
runat="server" and id="someid" attributes to the <head> tag of their .aspx
page. I was wondering if there is a way similar to the
RegisterClientScriptBlock method that can be used. Any ideas or suggestions?
Thanks.
--
Nathan Sokalski

http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      05-09-2006
Actually, I believe you can get away with RegisterClientScriptBlock even
though it is not "script". Try it.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"Nathan Sokalski" wrote:

> I want to dynamically add a stylesheet using <style type="text/css"></style>
> tags. The code that will use this stylesheet will be shared, so I will not
> have control over what the user does as far as stuff like adding
> runat="server" and id="someid" attributes to the <head> tag of their .aspx
> page. I was wondering if there is a way similar to the
> RegisterClientScriptBlock method that can be used. Any ideas or suggestions?
> Thanks.
> --
> Nathan Sokalski
>
> http://www.nathansokalski.com/
>
>
>

 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      05-09-2006
Thanks! It may not be the intended purpose, or even inside the <head> tag,
but it's good enough for me, and it works.
--
Nathan Sokalski

http://www.nathansokalski.com/

"Peter Bromberg [C# MVP]" <> wrote in message
news:05979FBF-CEE3-46B4-9E23-...
> Actually, I believe you can get away with RegisterClientScriptBlock even
> though it is not "script". Try it.
> Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "Nathan Sokalski" wrote:
>
>> I want to dynamically add a stylesheet using <style
>> type="text/css"></style>
>> tags. The code that will use this stylesheet will be shared, so I will
>> not
>> have control over what the user does as far as stuff like adding
>> runat="server" and id="someid" attributes to the <head> tag of their
>> .aspx
>> page. I was wondering if there is a way similar to the
>> RegisterClientScriptBlock method that can be used. Any ideas or
>> suggestions?
>> Thanks.
>> --
>> Nathan Sokalski
>>
>> http://www.nathansokalski.com/
>>
>>
>>



 
Reply With Quote
 
Flinky Wisty Pomm
Guest
Posts: n/a
 
      05-09-2006
I cheat. I've got two repeaters defined in my masterpages, one for
scripts, one for CSS. My base page class has a couple of List<string>'s
and I just call
AddResource("path/to/file", ResourceType.Css) to add resources to those
Lists

Then I bind the repeaters on PreRender so any page events have an
opportunity to add CSS/Js that'll be needed on the client. It's a hack,
but I like my stylesheets and scripts in external files referenced in
the head where they belong.

 
Reply With Quote
 
Edwin Knoppert
Guest
Posts: n/a
 
      05-09-2006
I don't get it but <%= ... > should do??
I'm using it for resolving the script url.


"Nathan Sokalski" <> schreef in bericht
news:...
>I want to dynamically add a stylesheet using <style
>type="text/css"></style> tags. The code that will use this stylesheet will
>be shared, so I will not have control over what the user does as far as
>stuff like adding runat="server" and id="someid" attributes to the <head>
>tag of their .aspx page. I was wondering if there is a way similar to the
>RegisterClientScriptBlock method that can be used. Any ideas or
>suggestions? Thanks.
> --
> Nathan Sokalski
>
> http://www.nathansokalski.com/
>



 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      05-09-2006
<%=...%> would be fine if I was writing the webform that used the
stylesheet, but I am not writing the webform, I am writing a couple external
classes that will be used with webforms.
--
Nathan Sokalski

http://www.nathansokalski.com/

"Edwin Knoppert" <> wrote in message
news:4460b513$0$2022$. ..
>I don't get it but <%= ... > should do??
> I'm using it for resolving the script url.
>
>
> "Nathan Sokalski" <> schreef in bericht
> news:...
>>I want to dynamically add a stylesheet using <style
>>type="text/css"></style> tags. The code that will use this stylesheet will
>>be shared, so I will not have control over what the user does as far as
>>stuff like adding runat="server" and id="someid" attributes to the <head>
>>tag of their .aspx page. I was wondering if there is a way similar to the
>>RegisterClientScriptBlock method that can be used. Any ideas or
>>suggestions? Thanks.
>> --
>> Nathan Sokalski
>>
>> http://www.nathansokalski.com/
>>

>
>



 
Reply With Quote
 
Martijn Saly
Guest
Posts: n/a
 
      05-10-2006
Flinky Wisty Pomm wrote:
> I cheat. I've got two repeaters defined in my masterpages, one for
> scripts, one for CSS. My base page class has a couple of List<string>'s
> and I just call
> AddResource("path/to/file", ResourceType.Css) to add resources to those
> Lists
>
> Then I bind the repeaters on PreRender so any page events have an
> opportunity to add CSS/Js that'll be needed on the client. It's a hack,
> but I like my stylesheets and scripts in external files referenced in
> the head where they belong.
>


That sounds like a much better solution. A <script> tag inside the body is
ugly (and invalid XHTML, I believe). And a <style> tag in the body is just
invalid in both HTML and XHTML.

And we all know that production-quality controls generate valid XHTML at
least, right?

--
Thanks,

Martijn Saly
 
Reply With Quote
 
MSDN
Guest
Posts: n/a
 
      05-11-2006
Flinky Wisty Pomm,

Can you please show an example.
why repeaters...>???

Thank you,

Sa


"Flinky Wisty Pomm" <> wrote in message
news: ups.com...
>I cheat. I've got two repeaters defined in my masterpages, one for
> scripts, one for CSS. My base page class has a couple of List<string>'s
> and I just call
> AddResource("path/to/file", ResourceType.Css) to add resources to those
> Lists
>
> Then I bind the repeaters on PreRender so any page events have an
> opportunity to add CSS/Js that'll be needed on the client. It's a hack,
> but I like my stylesheets and scripts in external files referenced in
> the head where they belong.
>



 
Reply With Quote
 
Kris
Guest
Posts: n/a
 
      07-08-2006
K.Scott Allen provided a useful trick for doing that.

The ContentPlaceHolder ¨C Not Just For Content
http://odetocode.com/Blogs/scott/arc...4/10/3258.aspx
 
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
Dynamically adding a stylesheet Nathan Sokalski ASP .Net Web Controls 8 07-08-2006 04:01 AM
Dynamically adding a stylesheet Nathan Sokalski ASP .Net 8 07-08-2006 04:01 AM
xml:stylesheet use in document with multiple stylesheet options David Blickstein XML 3 08-02-2005 03:10 PM
have a stylesheet generate another stylesheet based on XML? Steven An XML 1 11-23-2004 01:07 PM
Stylesheet referanse i stylesheet =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?= XML 3 07-04-2004 03:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57