As I command to call a .js file from my site master so that it is the first to be executed within my application.
SiteMaster code:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="sitemaster.master.cs" Inherits="sitemaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<script type="text/javascript" src="<%= ResolveUrl("login.js") %>"></script>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
JS code
$(document).ready(function () {
alert("Entro al JS");
});
But when running the application I do not get any message. And the location of the file is as follows:
I have also used the line of my script in the sitemaster as follows:
<script type="text/javascript" src="<%= ResolveUrl("~/login.js") %>"></script>
But neither of the two ways has worked for me. Another option he used was the classic one:
<script type="text/javascript" src="login.js"></script>
Also add jquery to my sitemaster's code, add it up in the head and call my file .js call it at the end of my body:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
If I add the lines of jquery and javascript code directly in my aspx (the view) in a traditional way it works correctly, but in the sitemaster I do it in the same order the two script links but it does not send me the message.
Code of login.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="login.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Hola Mundo"></asp:Label>
</div>
</form>
</body>
</html>