简体   繁体   English

如何将JavaScript文件刷新为asp.net中的UserControl

[英]how can refrence a javascript file to UserControl in asp.net

how can use from a js file in usercontrol in asp.net 如何从asp.net的usercontrol中的js文件使用

in webform put this line in head but in usercontol we have not head tag 在webform中将此行放在头部,但在usercontol中,我们没有head标签

<script src="../Scripts/tiny_mce/tiny_mce.js" type="text/javascript"></script>

Use ClientScriptManager.RegisterStartUpScript to set your scripts at the end of the page at server side. 使用ClientScriptManager.RegisterStartUpScript在页面的服务器端设置脚本。 Or use ready event of the JQuery ensure the dom is loaded, and then bind your client side events to your link. 或使用JQuery的ready事件来确保dom已加载,然后将客户端事件绑定到链接。

RegisterStartupScript , registers your scripts at the end of the page, so your script loaded after all the elements of the page loaded. RegisterStartupScript ,在页面末尾注册脚本,因此在加载页面的所有元素之后加载脚本。

One other option is to use ready event of the JQuery, it helps you to wait all elements of DOM loaded. 另一种选择是使用JQuery的ready事件,它可以帮助您等待DOM的所有元素加载。 You can implement your ready function at inline or server side. 您可以在串联或服务器端实现您的ready函数。

The key point here is to wait for the DOM elements load. 这里的关键点是等待DOM元素加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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