Solved

Calling a JavaScript file from a C# .aspx file (special case)

Posted on 2008-06-20
1
422 Views
Last Modified: 2013-12-16
Hi,

I'm building this website in which I have a C# .aspx page that doesn't allow for the <head>, <html> or <body> tags, otherwise I get the error:
"Only content controls are allowed directly in a content page that contains Content controls."

The same goes the this file master page.

I need to invoke from the .aspx file a JavaScript file:
<head>
<script><src="functions.js" type="text/javascript">
<head>

but I can't do it because, as I said, the page doesn't allow the <head> tag.

Putting the JavaScript code is not an option, because - I can't imagine why - it works in Firefox, but not in Internet Explorer.

So, my question to you, is how do I invoke the JavaScript file from the .aspx one under these conditions ?

Any help would be appreciated.

Warm Regards,
Mário Gamito
0
Comment
Question by:angelsofgrace2006
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 500 total points
ID: 21830555
Use Page.ClientScript.RegisterScriptInclude in your codebehind.
// check if it's already registered
if(!Page.ClientScript.IsClientScriptIncludeRegistered(this.GetType(), "MyFunctions"))
	Page.ClientScript.RegisterScriptInclude(this.GetType(), "MyFunctions", "functions.js");

Open in new window

0

Featured Post

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question