我需要能够为用户控件添加外部js文件(使用
this.Page.ClientScript.RegisterClientScriptInclude("SuggestionSearch",
"~/Secure/Shared/SuggestionSearch.js");
语法)
但它过早地将javascript文件放在页面上......有没有办法将文件放在页面底部?
答案 0 :(得分:2)
查看ClientScriptManager.RegisterStartupScript
这样的事情可行:
ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "SuggestionSearch",
String.Format("<script src='{0}' type='text/javascript'></script>", ResolveUrl("~/Secure/Shared/SuggestionSearch.js")));