register css dynamically in aspx page

Discussion in 'ASP .Net' started by Ryan Liu, Mar 16, 2009.

  1. Ryan Liu

    Ryan Liu Guest

    Hi,

    There is method like
    ClientScriptManager.IsClientScriptBlockRegistered()
    ClientScriptManager.RegisterClientScriptInclude()
    method to handle javascript file, where isn't similar mechanism for css
    file?

    What is the best way to register external css file dynamically in aspx file?

    For instance, I'd like to develop a user control which uses 3rd party
    javascript file and css file to support a tree structure in browser. In the
    user control, I want make the page uses this user control include necessary
    js and css files.

    Thanks a lot!
    Ryan
     
    Ryan Liu, Mar 16, 2009
    #1
    1. Advertising

  2. On Mar 16, 1:30 am, "Ryan Liu" <> wrote:
    > Hi,
    >
    > There is method like
    >     ClientScriptManager.IsClientScriptBlockRegistered()
    >     ClientScriptManager.RegisterClientScriptInclude()
    >  method to handle javascript file, where isn't similar mechanism for css
    > file?
    >
    > What is the best way to register external css file dynamically in aspx file?
    >
    > For instance, I'd like to develop a user control which uses 3rd party
    > javascript file and css file to support a tree structure in browser.  In the
    > user control, I want make the page uses this user control include necessary
    > js and css files.
    >
    > Thanks  a lot!
    > Ryan


    Hi Ryan

    add runat="server" to the head tag

    <head runat="server" id="head">

    then in Page_Load:

    Dim lc As New Literal
    lc.Text = "<link rel=""Stylesheet"" type=""text/css""
    href=""styles.css"">"
    Me.FindControl("head").Controls.Add(lc)

    Hope this helps
     
    Alexey Smirnov, Mar 16, 2009
    #2
    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. Jeremy
    Replies:
    1
    Views:
    7,716
    Brian Lowe
    Jun 24, 2004
  2. John M
    Replies:
    1
    Views:
    1,185
    Kumar Reddi
    May 29, 2005
  3. ColdAir
    Replies:
    1
    Views:
    785
    JeffP->
    Feb 26, 2009
  4. Arnaud PICHERY

    Adding a Register directive to an aspx page programmatically

    Arnaud PICHERY, Nov 16, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    381
    Teemu Keiski
    Nov 18, 2003
  5. Arnaud PICHERY
    Replies:
    0
    Views:
    155
    Arnaud PICHERY
    Nov 14, 2003
Loading...

Share This Page