简体   繁体   中英

Include Javascript file reference while using url routing asp .net 4.0

I am using url routing in my asp .net 4.0 application.

And I am using following referrence to call my javascript file.Its working fine in my devenv but when i Host in IIS .my javascript function in the file are not implemented

         <script type='text/javascript' src='<%= ResolveClientUrl("~/js/MYValidations.js") %>'></script>
<link rel="stylesheet" type="text/css" href="../css/style.css"  runat="server" />


I am getting this error

The Controls collection cannot be modified because the control contains code blocks (ie <% ... %>). [HttpException (0x80004005):

Try this

start the code block with <%# instead of <%= :

<script type="text/javascript" src='<%# ResolveUrl("~/js/MYValidations.js") %>'></script>

or

<script type="text/javascript" src='<%# ResolveClientUrl("~/js/MYValidations.js') %>"></script>

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