jquery not working in asp.net mvc after publishing to server - asp.net-mvc

I've built an mvc application which contains some jquery code. When I run the app from my ide, everything works perfectly. When I publish to the server and open the page, the jquery does not work. I get object expected errors.
Could this be due to my file mappings? here is a sample of my mapping in the app -
<script type="text/javascript" href="../../Scripts/jquery-1.3.2.js"></script>
I published the app to iis7 successfully, but the jquery is broken. I did publish to an application within an existing web site.
Any thoughts?

You may be experiencing problems with your relative path.
You can try this, which is a path from the application root:
<script type="text/javascript" href="/Scripts/jquery-1.3.2.js"></script>
Or this C# solution:
<script src="<%= Url.Content("~/Scripts/jquery-1.3.2.js") %>" type="text/javascript"></script>

Related

ASP.net MVC and Angular 4 - Zone already loaded

Application Background: My application is built up using ASP.net MVC(.net framework 4.6) and several Angular 4 mini SPAs
Shared view _Layout.cshtml have one mini SPA to show shopping basket contents and it is referenced using:
<script src="~/apps/shopping/inline.2785c74270c160e8df55.bundle.js"></script>
<script src="~/apps/shopping/polyfills.35726d60cdf25fecc5f1.bundle.js"></script>
<script src="~/apps/shopping/vendor.4918fe9ed7ea45b90ec8.bundle.js"></script>
<script src="~/apps/shopping/main.4d6729c54eca7c31dbba.bundle.js"></script>
Another view Order.cshtml have another SPA and it is referenced using:
#section scripts{
<script src="~/apps/userorder/inline.2a63d25fd80947ce8bb4.bundle.js"></script>
<script src="~/apps/userorder/polyfills.35726d60cdf25fecc5f1.bundle.js"></script>
<script src="~/apps/userorder/vendor.ec246c0701440a3e2ce3.bundle.js"></script>
<script src="~/apps/userorder/main.46be1befa8a20148f402.bundle.js"></script>}
Error
All looks good when I am at home view because on that page only 1 SPA is loaded
When I go to order view, I see below error in console window because now 2 SPAs have been loaded but still it works functionally.
I have already tried this and this
I am using Angular 4 with Angular CLI. Could anyone help me to get past this error, please?
I commented out import statement for zone in polyfill.ts and it worked like a charm.

PhoneGap asp.net MVC 4 network error

I publish my asp.net MVC project with visual studio then zip it and upload (with default page index.html )to build.phonegap.com it build project without errors.Then i download .apk but when store to my android mobile devices it gives this error what should i do?
this is my published project folder
folder
this is error : error
this is my index.html code
<html>
<head>
<script language="javascript">
window.location.href = "Home/Index"
</head>
<body>
</body>
</html>
Phonegap expects only html. You can't upload asp.net (or any other technology for that matter) project and expect it to work.
I suggest reading the documentation, starting here: https://build.phonegap.com/docs/preparing-your-app

Including JS files in JQuery Mobile

How and where to put your own JS files in JQueryMobile web applications?
Some suggestions I found:
only in the first page of the web app, usually index.html
inside the JQM page
Which one is better approach?
After your jQuery Library and BEFORE your jQuery mobile library. I place all my script tags at the end of the body...but that's not a must...
<script type="text/javascript" src="jQuerySource.js">
<script type="text/javascript">
/*Your stuff*/
</script>
<script type="text/javascript" src="jQueryMobileSource.js">
Why?: Because when you're building your jQM application you're going to want your event bindings to be defined before jQuery mobile gets initialized and fires the 'mobileinit' event and your first page's 'pageinit' event.
Just put your script after the JQM script tag
Yeah, that's all
It is a good idea to use jQueryMobile javascripts from Google CDNs because of following reasons:
1. You can directly include minified version in your pages.
2. You save bandwidth cost
3. Most importantly there are good chances that the JS might already be loaded on your user browser's. Because many other web apps use them.
So you should use
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js">
So, if all your code is inside document.ready() ; you can use it at end [ which loads the page faster]

How to migrate from jQuery Mobile 1.0 to 1.1

Now that the JQM 1.1 RC is out, I would like to migrate my 1.0 mobile app to this 1.1 version. How can I do that? Do I have to replace every file or just some specific files? What should be my migration path?
Edit: I plan to use my app using PhoneGap, which means, that I will want to have all resources locally, so no external references.
Adjust your jqm css and js references. Also, you'll need jquery 1.7.1
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0- rc.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"> </script>

asp.net mvc 3 unobtrusive client side validation not working in ie

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
type="text/javascript"></script>
<script src="//ajax.aspnetcdn.com/ajax/jQuery.Validate/1.7/jQuery.Validate.min.js"
type="text/javascript"></script>
<script src="//ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js"
type="text/javascript"></script>
I am using data annotations to display the error message. In Firefox its working fine, but in IE its not displaying the error message in the client side.
from the below link JQuery 1.6 $('form').validate() not working in IE7 & IE8, I came to see that
Jquery Validate does not currently work with jQuery 1.6 in IE6, IE7,
and IE8.
I am using jquery UI autocomplete,Datepicker in my project. So if i change the jquery version from 1.6.2 to jquery 1.5.2 my validation works fine, but my autocomplete starts failing.
how to solve this? any thoughts?
jQuery.validate 1.8.1 is release for 2001 may to be resolve this problem for ie, I integrated with my MVC 3 project with client side validation and it works perfect for me.

Resources