开发者

Add .js files at the bottom of the page from User Control

开发者 https://www.devze.com 2023-03-06 00:48 出处:网络
I have a user control on my web forms app and I need to reference a js file on the user control. I would like to add this js file at the bottom of the output html page but I don\'t know how to do it

I have a user control on my web forms app and I need to reference a js file on the user control.

I would like to add this js file at the bottom of the output html page but I don't know how to do it from User Control.

I have following script references on my master page;

<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.2.min.js"></script>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.12/jquery-ui.min.js"></script>
    <script src="http://ajax.cdnjs.com/ajax/libs/modernizr/1.7/modernizr-1.7.min.js" type="text/javascript"></script>

and they are staying just after the </body> tag at the bottom. I'm using my user control like below on a web form page;

<userControl:SearchEngine ID="SearchEngine" runat="server"></userControl:SearchEngine>

and from this user control, I would like to add the a js开发者_开发百科 at the bottom of the outputted html markup after the 3rd js file which you can see above.

any idea?


Try using RegisterClientStartUpScript() method to inject it at the end of the page:

http://msdn.microsoft.com/en-us/library/aa478975.aspx#aspnet-injectclientsidesc_topic2


Add a literal control at the bottom and set its text property with the content of the javascript file.

0

精彩评论

暂无评论...
验证码 换一张
取 消