Search code examples
c#asp.netvb.netstylesheetcontentplaceholder

Error when using link href inside my ContentPlaceHolder


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?


Solution

  • 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