Page 1 of 1
How to add code to head of specific page
Posted: Fri Oct 17, 2014 12:02 pm
by Brewhaus
We are trying to add some code from FB for a campaign that our SM person is running, but it requires us to put some code in the HEAD section of the final checkout page (Payment.ascx). We can easily add the code inside of a HEAD section, but that will give two head tags, which is probably sloppy code. Is there a way to add something to the head section on just this page?
Re: How to add code to head of specific page
Posted: Fri Oct 17, 2014 1:24 pm
by jguengerich
There may be a much easier way to accomplish this than what I have below, so if there is hopefully someone else will answer.
Caution: I did a very simple test and the following seemed to work, but I am still on R5. This assumes that Payment.aspx has a master page of /Layouts/Fixed/Checkout.master, which in turn has a master page of /Layouts/Fixed/Base.master, which already has this:
Code: Select all
<asp:ContentPlaceHolder ID="HtmlHeader" runat="server">
</asp:ContentPlaceHolder>
in it.
The Layouts/Fixed/Base.master file has a content place holder for the html header called "HtmlHeader". In the Layouts/Fixed/Checkout.master file, you could add a content section that refers to that, and provides another content place holder that could be used by Payment.aspx.
So checkout.master would have something like this right after the <%@.... lines at the top:
Code: Select all
<asp:Content ID="HtmlHeader2" runat="server" ContentPlaceHolderID="HtmlHeader">
<asp:ContentPlaceHolder ID="HtmlHeader3" runat="server"></asp:ContentPlaceHolder>
</asp:Content>
Payment.aspx would have something like this right after the <%@.... lines at the top:
Code: Select all
<asp:Content ID="MyCustomHtmlHeadStuff" runat="server" ContentPlaceHolderID="HtmlHeader3">
<%-- anything in this content area will be inserted in the HTML <head> element --%>
</asp:Content>
YMMV

Re: How to add code to head of specific page
Posted: Sat Oct 18, 2014 9:06 am
by Brewhaus
That appears to work (and I am on R8, so I assume that it will work for anyone on a Gold version). Thanks for the help!
