简体   繁体   中英

Including client-side scripts in head in ASP.NET

Hey guys. I don't do HTML or Javascript, I prefer to work in C#, but one of the JS guys tells me that he needs a script included within the head tag. The page in question is a content page of a master page. I can't seem to make this work. I tried adding the script by a programmatic reference this.ClientScript.RegisterClientScriptInclude , but it came out in the <body> tag. I tried adding a ScriptManager and a ScriptReference in the contentplaceholder inside the <head> tag of the master page, but this didn't work either. How can this be accomplished?

Just put a client side reference to the script in.

<head> <script lang="Javascript" src="./scripts/yourscript.js"></script>

Or, if it needs to be inline, include the actual script right there in the master page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM