register css dynamically in aspx page

R

Ryan Liu

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
 
G

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

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top