Head HTML code adds code to body, not to header

Targutai Yesugei asked on August 21, 2017 14:37

Hello again. I' m using Head HTML code webpart, but as described in subject, it adds code not to header but to body, into <asp:Literal runat="server" id="ltlTags"> in particular.

Can you help me? Thanks in advance.

Recent Answers


Brenden Kehren answered on August 21, 2017 15:24

How and where are you using this web part? The web part literally has one line of code to it that writes directly to the Head section of the page template

0 votesVote for this answer Mark as a Correct answer

Targutai Yesugei answered on August 22, 2017 05:58

I'm adding this webpart into my custom template page(it's just some html tags with web part zones). Also i have root master page with following layout

<head>
<title> Title </title>
    <meta http-equiv="pragma" content="no-cache" />
    <asp:Literal runat="server" ID="ltlTags" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on August 22, 2017 15:06

The HeadHtml Webpart uses this single line of code to add content to the HEAD section of the page.

Page.Header.Controls.Add(new LiteralControl(HTMLCode))

So if your custom master page template is not inheriting the proper namespace (should be PortalPage) properly and does not have the proper server tags on them (runat="server" there is a good chance your webparts and everything else might not work.

Take a look at the documentation for creating custom aspx master pages. If you're not using custom aspx templates then you or someone else have modified code where you shouldn't have and this will cause problems all over as this webpart is one of the simplest webparts included with Kentico.

0 votesVote for this answer Mark as a Correct answer

Targutai Yesugei answered on August 23, 2017 10:26

Thank you, Brenden, i'll check it.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.