Problems with javascripts files inserted in Masterpage

1

I can not use a tag contained in a file that is inserted in a MasterPage. Where can I go wrong?

Follow the MasterPage tag

<head runat="server">
    <title></title>
    <link href="Content/css/bootstrap.css" rel="stylesheet" type="text/css"/>
    <script src="Scripts/jquery-2.1.4.min.js" type="text/javascript"></script>
    <script src="Scripts/bootstrap.min.js" type="text/javascript"></script>
  <script type="text/javascript" src="Scripts/Formatacao.js"></script>


    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
    
asked by anonymous 26.06.2015 / 16:54

1 answer

0

I think the problem is in the hierarchy of your files, for example:

--- Aplicacao/
    ---- Scripts/
    ---- Content/
    ---- MinhaPasta/
         ---- MinhaPaginaQueNaoFunciona.aspx
    ---- Site.Master

What happens is that when you enter MinhaPasta to access the files in the Scripts folder, src="Scripts/jquery-2.1.4.min.js" does not work because it plays as src="MinhaPasta/Scripts/jquery-2.1.4.min.js"

To resolve this directory problem you can use .ResolveUrl ", like this:

<link href='<%= ResolveUrl("~/Content/css/bootstrap.css") %>' rel="stylesheet" type="text/css"/>
<script src='<%= ResolveUrl("~/Scripts/jquery-2.1.4.min.js") %>' type="text/javascript"></script>
<script src='<%= ResolveUrl("~/Scripts/bootstrap.min.js") %>' type="text/javascript"></script>
<script src='<%= ResolveUrl("~/Scripts/Formatacao.js") %>' type="text/javascript"></script>
    
26.06.2015 / 17:03