javascript - Working with a separate js file in asp.net mvc application -


i creating asp.net mvc application. want separate js code razor code in view. i've got file path "~/scripts/searchproductsscript.js" _layout.cshtml:

<head>     ...     <script src="@url.content("/scripts/jquery-1.10.2.min.js")"></script>     @if (issectiondefined("javascript"))     {         @rendersection("javascript", required: false)     }   ... </head> 

_someview.cshtml:

@section javascript {     <script type="text/javascript" src="@url.content("~/scripts/searchproductsscript.js")"></script> } 

and searchproductsscript.js:

var uri;  function test() {     alert("test"); }  $(document).ready(function () {     doing here     $(':radio').change(function () {         doing here     }); }); 

i'm not sure how use separate js file. none of functions working , trying call them _someview.cshtml doesn't work:

<script>     $(document).ready(function () { test(); }); </script> 

or

<input type="button" value="search" onclick="test();" /> 

so reason js code not called was trying set section partial view not possible. rendersection not working inside partial view in asp.net mvc3


Comments

Popular posts from this blog

4x4 Matrix in Python -

python - String indices must be integers and while issue -

python - PyInstaller UAC not working in onefile mode -