I am working on an aspnet MVC 3 project under visual 2012. I hava an Home/Index.aspx file which is referencing a remote javascripts ressource and css ressource like this:
<link rel="stylesheet" href="http://mottie.github.io/tablesorter/css/theme.bootstrap.css"/>
This is working without problem.
Now in order to boot my application pages loading, a have made a copy of those files in a local folder (Home/tablesorter) but when I reference them again it's not working:
<script type='text/javascript' src="tablesorter/js/jquery.tablesorter.js"></script>
I have tried this :
<script type='text/javascript' src="<%= Url.Content("tablesorter/js/jquery.tablesorter.js") %>"></script>
but without success.
Could you please tell me what's wrong with my code.
Thank you in advance (I am newer in .net)
Drag the JS or CSS file from folder and drop on aspx page it will automatically add the correct path.
Related
So I have this web app which runs just fine when I debug it using IIS Express, it's using the correct css files and what not.
But if I try running it as the project exe, it doesnt seem to find this path
<link href="~/assets/css/dark_theme.css" rel="stylesheet">
And I'n my startup.cs I'm using
app.UseStaticFiles();
When i run the executable inside
bin\Debug\netcoreapp3.1
Do I then need to change this path href="~/assets/css/dark_theme.css" to something else?
Update this:
<link href="~/assets/css/dark_theme.css" rel="stylesheet">
to
<link href="./assets/css/dark_theme.css" rel="stylesheet">
I am working on ASP.NET core 3.1. I want to do a simple application. I have a very basic problem but I cannot find a good way to solve it.
I have the menu of the application in a Shared view _Layout.cshtml. In this view i am loading .js and .css libs with:
<script src="assets/libs/jquery/dist/jquery.min.js"></script>
Everything is working fine, the menu is correctly displayed, and I can display my Index.cshtml with the #RenderBody().
The problem is that when I want to go to another page using:
<a asp-area="" asp-controller="Home" asp-action="Privacy" aria-expanded="false"><span>Privacy</span></a>
or
<span>Privacy</span>
the page will be loaded trying to fetch the libs from :
<script src="Home/assets/libs/jquery/dist/jquery.min.js"></script>
And it won't find them.
I would like to know what is the best practice to avoid this issue.
Thank you for your help.
In asp .net core static files should be placed inside wwwroot folder. Thats why put static files inside wwwroot folder and give reference to _Layout.cshtml like this,
<script src="~/JavaScript/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="~/CSS/styles.css"/>
I am trying to include angularjs framework into a existing web forms application. But I am not able to access the angular directives from the aspx pages. I am sure there is some part of settings that I am missing. I added the angularjs package using the nuget installer. It created a directory "Scripts" and dumped all the angularjs related files. Can any body help me in putting up the settings correct so that I can make use of angularjs directives on the apsx pages.
Thanks in advance for the help and suggestions.
Include the script:
<script src="angular.js" type="text/javascript"></script>
Add ngApp to the body tag:
<body ng-app="app">
...
</body>
In your script define your module:
<script>
var app = angular.module('app',[]);
</script>
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to add external JavaScript or CSS files to our Tridion page?
I want to add the .css and .js files to the Tridion server.
I want to refer them in the TBBs.
<link href="path/style.css" rel="stylesheet" type="text/css" />
<script src="path/script.js" type="text/javascript"></script>
I have some questions:
Do I need to place them directly in Tridion server machine?
Do I need to add them in IIS as virtual directories to refer them?
In either of the ways I am not sure how to give the "href".
I am using Dreamweaver TBBs and SDL Tridion 2011 SP1.
I know that there are other ways to handle the .css and scripts.
But my requirement needs them to add directly in server.
Please share your suggestions.
It all depends on where the files are on the local disk (which unfortunately you fail to mention in your question).
If you have the files on disk like this:
c:\
inetpub
wwwroot
mywebsite
index.html
style.css
script.js
And you have created a web site with its root at c:\inetpub\wwwroot\mywebste, then you can refer to style.css and script.js from within index.html as
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="script.js" type="text/javascript"></script>
If however you created a web site with its root at c:\inetpub\wwwroot, you'd refer to the same files as:
<link href="mywebsite/style.css" rel="stylesheet" type="text/css" />
<script src="mywebsite/script.js" type="text/javascript"></script>
Either way, you will have to ensure that the files are placed onto the web server. You can either do that through Tridion or by placing them there manually.
If you want to publish the CSS and JavaScript files from Tridion, I suggest reading this question: How to add external JavaScript or CSS files to our Tridion page?
Anyone knows how to include javascript file as project's resource for aspx.cs files under different folders to use?thanks very much
Suppose your project's directory looks like:
/App_Code
/App_Data
/App_Themes
/Master_Pages
...
web.config
Add a folder called "scripts" so you have:
/App_Code
/App_Data
/App_Themes
/Master_Pages
/scripts
...
web.config
Put your javascript file in this scripts folder.
Put the script tag in any of your aspx pages.
<script src="/ProjectRoot/scripts/your-file.js" type="text/javascript"></script>
The key to remember is the path you specify in the src attribute. This is relative to the root of your domain. If you are developing on your machine and you test your project at:
http://localhost:2430/SomeProject/
Then your script tag needs to look like:
<script src="/SomeProject/scripts/your-file.js" type="text/javascript"></script>
If your project is deployed on a server at the root: http://www.example.com/
Then your script tag needs to look like:
<script src="/scripts/your-file.js" type="text/javascript"></script>
If your project is deployed on a server at the root: http://www.example.com/SomeApp
Then your script tag needs to look like:
<script src="/SomeApp/scripts/your-file.js" type="text/javascript"></script>
FYI, because the script tag is not a server-side tag you can't use the "~/" syntax. And because you can't use the "~/" syntax, you (usually) can't use a relative path for the src attribute but instead have to specify an absolute path from the root of your domain.
Put the javascript file in a folder in the web application project.
In pages where you want to refer the javascript file you can add this in your aspx file.
<script src="path_to_yourfile" type="text/javascript"></script>