I am currently working on the basics of a .NET C# Razor page application running the following:
My current issue is that jQuery (and plain JS) are only working in the Layout.cshtml file, I have tried the following:
At this stage I am fairly sure it is just a case of, it needs to be setup in a very particular way in .NET5, but I really have no more clues
Bottom of _Layout.cshtml
</header>
<div class="container-fluid">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@RenderSection("Head", required: false);
@RenderSection("Scripts", required: false);
</body>
</html>
Bottom of the index.cshtml file
@section scripts {
<script>
$(document).ready(function () {
$(".btn-reply").click(function (event) {
alert("it works");
});
});
</script>
}
Rather frustratingly this turned out not to be anything JS related at all, in actually fact this was down to main div with the class of row having a z-index of -1, no idea how this came to be, I don’t recal having set this, but if I did I whole apologise to anyone who took the time to read this.