C# MVC5 Upgrade broke Javascript loading - asp.net-mvc

Just upgraded a very old project from MVC 4 to 5 and now after the upgrade the Razor Partial views which were working fine no longer work.
By this I mean that in the partial views there is a Script file that is called at the bottom:
<script src="~/Scripts/simAvail.js" type="text/javascript"></script>
And this was loading the JS and in that file some JQuery added CSS etc as needed to the elements on the page. However after the upgrade this JS file is no longer loaded and I use this method on many pages in the project so wondered if anyone knows the reason why.
The data in the Partial view is loaded and displayed but all the styling and reading/posting of the changes via Ajax is no longer there as this is what the JS file adds to the page.
Thanks

I Managed to fix this it turns out that when the upgrade to MVC5 happened part of the process as detailed on the MS instructions was to re-install all the Nuget's. This part actually installed the latest versions of all the JS packages like JQuery/Knockout etc without me noticing.
This then caused there to be two versions of everything being loaded and thus caused the issue. SO I deleted the old version of the JS packages and back running.

Related

asp mvc 6 include ckeditor via bower

I've included CKEditor (4.5.3) via bower.js, but on the View, I just can't figure out how to make it work.
I'm working on a default MVC6 project template and I haven't changed any gulp.js paths.
I'm guessing I'm missing something there, since It wants to join scripts from paths.webroot + "js/**/*.js";
and the CKEditor is located inside wwwroot/lib/ckeditor
Everything works fine if I add <script src="/lib/ckeditor/ckeditor.js"></script> on the View...
But that's missing the point, since gulp should take care of it.
Can anyone please help?

Issue with Bundling and Minification of CSS after NuGet update (ASP MVC 4)

I just ran a Update-Package on a fresh asp mvc 4 project using the mobile template. Update-Package updates every nuget packages in the project and Web.Optimization did not get updated. After the update won't it render the css bundle when I use "Debug="false" in web config, though it worked before the update. Anyone have had simlar problems? I've done no changes to the code.
It works as it should when I set "Debug=true", but then it's not bundeling and minifying the css. When I load the page in a browser and open the developer tools (like firebug) can I still both find and view the minified css file. Any suggestions or ideas would be greatly appriciated.

Error loading external URL in Phonegap 2.5

I created a new Phonegap 2.5 project from scratch, and I've been trying to load an external URL in it, but I keep getting input boxes popping up on startup before loading the actual URL. I first get a pop-up with the URL of the website, then in the input box it says "DeviceInfo","Device652321624". If I click Cancel, it pops up 2 more times before loading the website. On the website itself, it loads some relative URLs, but others cause the entire page to refresh and the input boxes to pop up again.
I set the URL by setting <content src="http://phonegap.example.com" />, which is just a regular website with Javascript. I even tried commenting out all Phonegap specific code (no more ondeviceready calls), but it still causes the problem. http://www.google.com loads for me, so I'm not sure what else to check. And it works with the Android version that I've developed.
If it helps, I've also seen this message in the XCode log: Resetting plugins due to page load.
I've had the exact same problem today.
I fixed it by checking the include of the cordova.js file (this js is generated when you create the project using the create command.
( called cordova.js in the renamed cordova project version. probably phonegap.js in phonegap ?)
anyway my include was :
<script type="text/javascript" src="js/cordova.js"></script>
whereas je js file was in the project root :
I changed it to
<script type="text/javascript" src="cordova.js"></script>
and every things is fine now.
also, the 'create' command for Android generate a different js file. make sur that the new one generated for ios is used.
hope that helps !
Problem is you are using android's cordova.js instead of ios's cordova.js.
Just make sure you are using the proper one.

Unable to Bundle JQuery Mobile 1.2 in ASP.NET MVC 4 app

I'm working on an ASP.NET MVC 4 app. This app leverages bundling to improve performance. Previously, the app was using jquery.mobile-1.1.0.js. Everything worked fine. However, I've upgraded to JQuery Mobile 1.2 and when I load my screen, I always see a wait spinner. I've pinpointed it to the fact that both the standard and the minified versions are being referenced. When I look in my view-source after the page is loaded, I see the following at the top:
<script src="/Scripts/jquery.mobile-1.2.0.js"></script>
<script src="/Scripts/jquery.mobile-1.2.0.min.js"></script>
From what I can tell, this was generated from the following in my ASP.NET MVC .cshtml file
#Scripts.Render("~/bundles/jquerymobile")
In my BundleConfig.cs file, I have the following definition:
bundles.Add(new ScriptBundle("~/bundles/jquerymobile").Include("~/Scripts/jquery.mobile*"));
Essentially, I want to use the normal version when the debug="true" flag is set in my web.config compilation setting. However, when debug="false", I want to use the minified version. What am I doing wrong?
Thank you
This should happen automatically for you already (assuing the fileextensionreplacement lists still have the default "min" entry for when optimizations are enabled).
As a workaround, you could try this instead which should also work:
.Include("~/Scripts/jquery.mobile-{version}.js"));
This basically is similar to your * except it will regex match for version strings. Note, both this and what you have require that you only have the latest jquery in your Scripts folder, if you still have the 1.1 version there, you will end up with both versions in your page.

Telerik MVC controls still loading jQuery Validation even after setting it not to

I have a project I'm working on and I'm using the Telerik MVC controls. I have the newest open source version.
In my _Layout.cshtml, I have the following line:
#(Html.Telerik().ScriptRegistrar().DefaultGroup(group =>
group.Combined(false)
.Compress(false))
.jQuery(false)
.jQueryValidation(false))
I want to load jQuery and jQueryValidation myself by using Cassette. The above line keeps jQuery from loading in favor of the location and version I've specified.
My problem is that when I bring up a page with a grid on it, the jquery.validation.min.js that exists in the telerik script directory still gets loaded as well as the one I have specified from a different directory.
Why is the ScriptRegistrar still loading jQueryValidation?
There was a bug which caused this erroneous behavior. Try downloading the latest internal build.
Another approach is to replace the jquery.validation.min.js that exists in the telerik script directory with an empty file.

Resources