1

This is the formal structure of my .cshtml file

<!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Dashboard</title>
    <link rel="stylesheet" href="~/lib/Hover/hover.css" />
    <link rel="stylesheet" href="~/lib/fontawesome/css/font-awesome.css" />
    <link rel="stylesheet" href="~/lib/weather-icons/css/weather-icons.css" />
    <link rel="stylesheet" href="~/lib/ionicons/css/ionicons.css" />
    <link rel="stylesheet" href="~/lib/jquery-toggles/toggles-full.css" />
    <link rel="stylesheet" href="~/lib/morrisjs/morris.css" />
    <link rel="stylesheet" href="~/lib/select2/select2.css" />
    <link rel="stylesheet" href="~/lib/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css" />

    <link rel="stylesheet" href="~/css/quirk.css" />

    <script src="~/lib/modernizr/modernizr.js"></script>

    <script>
       alert("hello from top");
    </script>    

</head>

<body style="background:none;">
---Several divs------

   <script src="~/lib/jquery/jquery.js"></script>
    <script src="~/lib/jquery-ui/jquery-ui.js"></script>
    <script src="~/lib/bootstrap/js/bootstrap.js"></script>
    <script src="~/lib/jquery-toggles/toggles.js"></script>

    <script src="~/lib/morrisjs/morris.js"></script>
    <script src="~/lib/datatables/jquery.dataTables.js"></script>
    <script src="~/lib/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.js"></script>
    <script src="~/lib/select2/select2.js"></script>

    <script src="~/js/quirk.js"></script>

    <script>
       alert("hello from bottom");
    </script>
</body>
</html>

Actually It's the design provided by our designer, The first alert message from head is popping up successfully so that it's sure javascript is not disabled in my browser, But the last alert is never shown. When I link the external scripts then that also never works either. This is really annoying. I referenced this question and many more in stackoverflow, But nothing solved.

How can I find out what actually happened here ? Is it because some error in previous js files ? OR it's because of old html4 ? There is nothing in my Action method except return View(); statement so that I think it's not necessary to post.

One additional thing is I've rendered one partial view using @Html.Action("...") in body, I think it's not the issue because I tried removing it as well. Please guide me, I am a beginner.

Community
  • 1
  • 1

1 Answers1

0

It's seems the same mistake I did some months ago. Your page is started from

<!DOCTYPE ...>
<html ...>

means It clarifies that you are not using any master layout page so any kind of @Scripts.Render as given in the answer you referenced won't work in the current situation. Just a simple solution is set Layout to null at the top of the page like,

@{
    Layout = null;
    ...
}

and everything will work fine.

Shree Krishna
  • 8,474
  • 6
  • 40
  • 68
  • Woww, It was really a silly mistake I ever done, Sorry I couldn't vote your answer but thank u very much it's working. I thought adding view by unchecking the master layout option will set the layout null automatically, But I mistakely replaced that all... Thank you very much – Rosan Shrestha May 17 '16 at 17:15
  • @RosanShrestha Yah once I faced that as well. glad to hear. – Shree Krishna May 17 '16 at 17:20