Error when using link href inside my ContentPlaceHolder
Asked Answered
R

1

2

I am using a MasterPage in my project...

This this the link i need to place inside my ContentPlaceHolder of my Dedault.aspx page

<link href="jquery/imagebox/imagebox.css" rel="stylesheet" />

But i get a error "Element link cannot be nested within element td"

Any idea what to do?

Radiopaque answered 6/4, 2009 at 18:20 Comment(1)
I added another content Placeholder in my site.master for scripts. It is in the header above the title. other pages do not need extra scripts or css it does not get used. when I need extra scripts or css on the page it goes in there.Wehrle
F
4

You can only place stylesheet links in the header of the document. Here's a link how to do that from a ContentPlaceholder:

http://www.odetocode.com/articles/450.aspx

Quote:

Protected Sub Page_Load(ByVal sender As Object, _
                         ByVal e As System.EventArgs)

   Dim cssLink As New HtmlLink()
   cssLink.Href = "~/styles.css"
   cssLink.Attributes.Add("rel", "stylesheet")
   cssLink.Attributes.Add("type", "text/css")
   Header.Controls.Add(cssLink)

End Sub
Famulus answered 6/4, 2009 at 18:23 Comment(6)
Then where must i place it? Because i cant use a header in my Default.aspx page since i am using MasterPages.Radiopaque
Seems you can actually - I amended my answer :)Famulus
@Radiopaque - you can use contentplaceholders in "head" element too.Loats
@Loats - what will the syntax be for that?Radiopaque
@Mladen - thanks it does work, but it placed the link inside my actual MasterPage and because of this it does not work for me. For some reason it must be at the Default.aspx level.Radiopaque
If I understand correctly it placed it in the HEAD tag of which you have only one (the masterpage creates it) so it can only put it there. You cannot link to a style outside it. Why would you want to?Famulus

© 2022 - 2024 — McMap. All rights reserved.