Skip to main content
added code
Source Link
Kyle Trauberman
  • 25.6k
  • 13
  • 86
  • 122

I had this problem a while back, and I ended up not using RegisterClientScriptInclude.

I placed a placeholder in the header of the page, and added the script tag to the placeholder via a HtmlGenericControl.

I'll see if I can find my code and I'll edit my answer with it.

EDIT

I couldn't find my code, so I just re-created it:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <asp:PlaceHolder runat="server" ID="HeadPlaceHolder"></asp:PlaceHolder>
</head>    
<body>
    ...
</body>
</html>

And the Code Behind:

protected void Page_Load(object sender, EventArgs e)
{
    HeadPlaceHolder.Controls.Add(/* Your control here */);
}

I had this problem a while back, and I ended up not using RegisterClientScriptInclude.

I placed a placeholder in the header of the page, and added the script tag to the placeholder via a HtmlGenericControl.

I'll see if I can find my code and I'll edit my answer with it.

I had this problem a while back, and I ended up not using RegisterClientScriptInclude.

I placed a placeholder in the header of the page, and added the script tag to the placeholder via a HtmlGenericControl.

I'll see if I can find my code and I'll edit my answer with it.

EDIT

I couldn't find my code, so I just re-created it:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <asp:PlaceHolder runat="server" ID="HeadPlaceHolder"></asp:PlaceHolder>
</head>    
<body>
    ...
</body>
</html>

And the Code Behind:

protected void Page_Load(object sender, EventArgs e)
{
    HeadPlaceHolder.Controls.Add(/* Your control here */);
}
Source Link
Kyle Trauberman
  • 25.6k
  • 13
  • 86
  • 122

I had this problem a while back, and I ended up not using RegisterClientScriptInclude.

I placed a placeholder in the header of the page, and added the script tag to the placeholder via a HtmlGenericControl.

I'll see if I can find my code and I'll edit my answer with it.