RegisterClientScriptInclude and master page


Dave Mathew

Is there any way to use RegisterClientScriptInclude to generate the
script tags inside of the <head> tag?

I'm using RegisterClientScriptInclude inside of Page_Load event in the
code behind for the master page and it generates the tags to the page
ok, however it puts them inside where the <form> tag begins on the
page and not inside the head tag

In the code behind:

What gets rendered to the browser:

<html xmlns="">
Untitled Page
</title><link rel="stylesheet" type="text/css" href="../stylesheets/
main.css" />
<title>Page Title</title>
<form name="aspnetForm" method="post" action="Default.aspx"
<script src="../javascript/master.js" type="text/javascript"></

bruce barker


RegisterClientScriptBlock & RegisterClientScriptInclude, always come after
the form, before any form content. RegisterStartupScript is rendered before
the closing tag.

you can put a placeholder inside the <head> and render your own script, but
any server controls will still call the Register routines

-- bruce (

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