Add Css File

Discussion in 'ASP .Net' started by shapper, Apr 16, 2008.

  1. shapper

    shapper Guest

    Hello,

    I am adding, in a page, a reference to a CSS file at runtime as
    follows:

    Dim base As HtmlGenericControl = New HtmlGenericControl("style")
    With base
    .Attributes.Add("type", "text/css")
    .Attributes.Add("media", "Screen")
    .InnerText = "@import url(App_Assets/PT/Styles/Base.css);"
    End With
    Page.Header.Controls.Add(base)

    In which Page Event should I do this?

    Thanks,

    Miguel
     
    shapper, Apr 16, 2008
    #1
    1. Advertising

  2. shapper

    nick chan Guest

    Init, page load or page complete . ur choice
    On Apr 16, 8:51 am, shapper <> wrote:
    > Hello,
    >
    > I am adding, in a page, a reference to a CSS file at runtime as
    > follows:
    >
    >     Dim base As HtmlGenericControl = New HtmlGenericControl("style")
    >     With base
    >       .Attributes.Add("type", "text/css")
    >       .Attributes.Add("media", "Screen")
    >       .InnerText = "@import url(App_Assets/PT/Styles/Base.css);"
    >     End With
    >     Page.Header.Controls.Add(base)
    >
    > In which Page Event should I do this?
    >
    > Thanks,
    >
    > Miguel
     
    nick chan, Apr 16, 2008
    #2
    1. Advertising

  3. This one is pretty wide open, as far as events, but why do this at all.

    A better option, in many cases, is to set up themes. You can then use your
    base class (from another thread) and set the theme there. Then you do not
    end up creating dynamic links to CSS pages, which are harder to control.

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    Subscribe to my blog
    http://gregorybeamer.spaces.live.com/lists/feed.rss

    or just read it:
    http://gregorybeamer.spaces.live.com/

    *************************************************
    | Think outside the box!
    |
    *************************************************
    "shapper" <> wrote in message
    news:...
    > Hello,
    >
    > I am adding, in a page, a reference to a CSS file at runtime as
    > follows:
    >
    > Dim base As HtmlGenericControl = New HtmlGenericControl("style")
    > With base
    > .Attributes.Add("type", "text/css")
    > .Attributes.Add("media", "Screen")
    > .InnerText = "@import url(App_Assets/PT/Styles/Base.css);"
    > End With
    > Page.Header.Controls.Add(base)
    >
    > In which Page Event should I do this?
    >
    > Thanks,
    >
    > Miguel
     
    Cowboy \(Gregory A. Beamer\), Apr 16, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. babu dhayal via .NET 247

    How to add shared assembly in the add reference

    babu dhayal via .NET 247, Aug 5, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    6,261
    Nelson Xu
    Aug 17, 2004
  2. VSK
    Replies:
    3
    Views:
    5,045
    S. Justin Gengo
    Nov 25, 2003
  3. Chad Scharf
    Replies:
    3
    Views:
    924
    Chad Scharf
    Oct 18, 2007
  4. rs387
    Replies:
    3
    Views:
    275
    rs387
    Oct 2, 2008
  5. tania tani
    Replies:
    0
    Views:
    331
    tania tani
    Aug 3, 2010
Loading...

Share This Page