I just created a new ASP.Net MVC3 project, and it won't load any scripts from the Scripts folder, gives me a 404 when I debug.
How in the world do I fix this?
included like this:
<script type="text/javascript" src="../../Scripts/jquery.validationEngine.js"></script>
<script type="text/javascript" src="../../Scripts/languages/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="../../Scripts/bootstrap-transition.js"></script>
<script type="text/javascript" src="../../Scripts/bootstrap-alert.js"></script>
<script type="text/javascript" src="../../Scripts/bootstrap-modal.js"></script>
or using a Global variable in App_Code like this:
public static readonly string JSDir = "../../Scripts";
In my view:
<script type="text/javascript" src="#GlobalVal.JSDir/jquery.validationEngine.js"></script>
<script type="text/javascript" src="#GlobalVal.JSDir/languages/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="#GlobalVal.JSDir/bootstrap-transition.js"></script>
<script type="text/javascript" src="#GlobalVal.JSDir/bootstrap-alert.js"></script>
<script type="text/javascript" src="#GlobalVal.JSDir/bootstrap-modal.js"></script>
Tried this, too:
<script type="text/javascript" src="#Url.Content("~/Scripts/jquery.validationEngine.js")"></script>
<script type="text/javascript" src="#Url.Content("~/Scripts/languages/jquery.validationEngine-en.js")"></script>
<script type="text/javascript" src="#Url.Content("~/Scripts/bootstrap-transition.js")"></script>
<script type="text/javascript" src="#Url.Content("~/Scripts/bootstrap-alert.js")"></script>
<script type="text/javascript" src="#Url.Content("~/Scripts/bootstrap-modal.js")"></script>
Either way, same result. 404 for all files in Scripts folder.
A Web.config file had been placed in that directory that had the http handler to block serving anything from that folder.
Related
I am using google prettify code in my blog to syntax highlighting but last few days, all of sudden it discontinue to work. I have included js/css files in my blogspot theme, moreover when I hit these files link directly in to my browser it throws message error page 404. I am sharing files included in my blogspot theme here as follows:
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shCore.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushDelphi.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://syntaxhighlighter.googlecode.com/svn/trunk/Scripts/shBrushXml.js' type='text/javascript'/>
Can anyone help me out why not working.
I think Google is withdrawing from his service, alternatively I added a new open sourced syntax highlighter of this site. Put below code just before end head tag in template.
<!-- Syntax Highlighter Additions START -->
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>
<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<!-- Syntax Highlighter Additions END -->
Csharp Code to highlight csharp code:
<pre class="brush: csharp;">
function helloSyntaxHighlighter()
{
return "hi!";
}
Google Deprecated Code Prettify Showing Link
http://java-prettify.googlecode.com/svn/trunk/javadoc/deprecated-list.html
In the default _Layout.cshtml file, scripts are defined in "environment"s like so:
<environment names="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
</environment>
<environment names="Staging,Production">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal">
</script>
<script src="~/js/site.min.js" asp-append-version="true"></script>
</environment>
And below that is #RenderSection("scripts", required: false)
I can't seem to implement a section (in this case "scripts") in any separate .cshtml file since it looks like they got rid of "#section" in Core
I would like to add specific scripts for specific views. What is the new way to go about this? Do I just dump everything in _Layout now?
I think you are mistaken. It works just fine in ASP.NET Core. I have this in my _layout.cshtml
#RenderSection("scripts", required: false)
and in one of my views I'm adding scripts there like this:
#section Scripts {
#if (Model.CanEdit)
{
await Html.RenderPartialAsync("EditorScriptsPartial");
}
}
Does anyone have some css styles and images to apply to jqTree to show the outline of the tree? Something like YUI treeview that shows a dotted border
http://developer.yahoo.com/yui/examples/treeview/default_tree.html
Turns out YUI treeview allows you to use existing html to render.
<script src="scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="scripts/tree.jquery.js" type="text/javascript"></script>
<!-- Required CSS -->
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.9.0/build/treeview/assets/skins/sam/treeview.css">
<!-- Dependency source file -->
<script src="http://yui.yahooapis.com/2.9.0/build/yahoo-dom-event/yahoo-dom-event.js" ></script>
<!-- Optional dependency source file to decode contents of yuiConfig markup attribute-->
<script src="http://yui.yahooapis.com/2.9.0/build/json/json-min.js" ></script>
<!-- TreeView source file -->
<script src="http://yui.yahooapis.com/2.9.0/build/treeview/treeview-min.js" ></script>
<script>
var tree;
function treeInit() {
tree = new YAHOO.widget.TreeView("committeeTree");
// if required, add nodes here
tree.render();
}
$(function () {
$("#myTree").tree({
data: source
});
treeInit();
});
</script>
I have two javascripts that I think are in a conflict. idTabs, which helps me make the navigation and lightbox, which is the photo gallery. I also want to add that I have a 3rd page linked, a PHP SELECT from database page.
this is in my head
<title>Untitled Document</title>
<script type="text/javascript" src="jquery.idTabs.min.js"></script>
<script type="text/javascript" src="lightbox0/js/jquery.js"></script>
<script type="text/javascript" src="lightbox0/js/jquery.lightbox-0.5.js"></script>
> <link rel="stylesheet" type="text/css" href="lightbox0/css/jquery.lightbox-0.5.css" media="screen" />
<script type="text/javascript">
$(function() {
$('#gallery a').lightBox();
});
</script>
I dont understand what the light box doesn work. the id tabs works perfectly but when i click on a page, it doesn have the lightbox effect. i tried with at least 4-5 lightobx versions, the same effect. help ?
idTabs should be loaded after jQuery. Try the following:
<script src="lightbox0/js/jquery.js"></script>
<script src="lightbox0/js/jquery.lightbox-0.5.js"></script>
<script src="jquery.idTabs.min.js"></script>
Sanity Check: Do you have a <div id="gallery"> with links in it in the page?
I am using jQuery session in my master page. Anything I'm missing?
Code:
<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.session("lnkID","A1")
});
</script>
Error:
Microsoft JScript runtime error: Object doesn't support this property or method
By your example alone, you're missing a reference to the required files, and you're not wrapping your jQuery code in script tags. You need to reference not only jquery-source, but jquery-json, and jquery-session as well.
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/jquery.json.js"></script>
<script type="text/javascript" src="scripts/jquery.session.js"></script>
Once you've got those in place, you need to place your logic within script tags:
<script type="text/javascript">
$(function(){
$.session("foo", "bar");
});
</script>
See the following demo for an example: http://www.jaysalvat.com/session/test1.html
Lastly, the language attribute of the script tag is deprecated. You can do away with it, but keep the type attribute.