Must be a simple question, but I cannot for the life of me figure out how to include a script manager in my view. <asp:ScriptManager /> doesn't work. Anyone know?
ScriptManager is a webforms specific construct, so if you are using MVC, you won't (and shouldn't) be able to use it. You can look at http://mvcscriptmanager.codeplex.com/ if you want something that ports some of the features of the scriptmanager to MVC.
I ran into a similar situation upgrading a project.
For "simple-ish" WCF Ajax services, I was able to get this work by adding:
<script src="#Url.Content("~/Scripts/MicrosoftAjax.js")" type="text/javascript"></script>
<script type="text/javascript" src="#Url.Content("~/Services/SampleService.svc/jsdebug")"></script>
and then create my service object the old fashion way:
var dataService = new SampleService();
dataService.doBar(fooCallback,fooErrorMethod,null);
I haven't tested this is extensively, but Hey, isn't that why the word "kludge" became an official developer term.
Related
I'm using the sample here to embed a Power BI report into a web application.
The application compiles properly, but I'm getting an error involving Promises. I've tracked down the solution here. It seems that I need to add the following somewhere in my application:
<script src="https://npmcdn.com/es6-promise#3.2.1"></script>
However, I have absolutely no idea where this script tag should go. Any suggestions? Thank you.
The es6-promise library is a polyfill for Promises, mostly used in IE.
If you need it, you just need to put it anywhere in your <head> tag, preferably before your <script src='.../powerbi.js>.
For more info on es6-promise: https://github.com/stefanpenner/es6-promise
I am using breeze with angular.
I have upgrade breeze to 1.4.11 and install breeze.angular.js.
The beginnings of a "breeze service" that tells Breeze to
use $q for its promises rather than Q.js
use $http for AJAX calls.
Consequently Breeze no longer requires the jQuery or the Q.js libraries
although non-Breeze code in your app may require either or both.
My problem is that I am still using breeze.savequeuing.js which requires window.Q.
Is there any official solution for this scenario or I have to manually change breeze.savequeuing.js?
It is simple. I can use HACK from angular.breeze.js breeze.Q is $q
We do not yet have an Angular version of breeze.savequeuing. It's on my backlog but way down the list as I try to discourage folks from getting in a situation where it is needed.
You are welcome to write one and contribute it. I recommend writing it as a real ng service rather than a simple Q-for-$q hack. If you like I'll look it over and give you my thoughts.
All the best.
As you mention "discouraging folks ..." I have to mention that the Breeze Todo Sample makes use of breeze.savequeuing.js:
<!-- 3rd party libraries -->
<script src="Scripts/angular.js"></script>
<script src="Scripts/jquery-1.8.3.min.js"></script>
<!-- Q is needed by breeze.savequeuing, not by Breeze-->
<script src="Scripts/q.min.js"></script>
<script src="Scripts/breeze.debug.js"></script>
<script src="Scripts/breeze.angular.js"></script>
<script src="Scripts/breeze.savequeuing.js"></script>
<script src="Scripts/toastr.js"></script>
Perhaps you may use this sample to show everyone to show how not to get into the situation where savequeuing.js is needed :-)
We would like to make jquerymobile lighter by removing modules we dont need.
Want to keep only some widgets, ui control decorations and touch event processing.
Would also like to use Zepto instead of the full jquery library...
Thank you!
jQM is now decoupled:
http://jquerymobile.com/blog/2011/08/03/jquery-mobile-beta-2-released/
Widgets: Now decoupled for flexible builds
We’ve wanted to decouple all our widgets from the page plugin for a
long time now and we’re happy to announce that we finally landed this
change. So what exactly does decoupled mean anyway? Well, the
individual widgets and utilities have always been broken out into
separate script files. However, the page plugin was responsible for
handling the auto-initialization all of the official plugins found in
the markup at page creation. This situation made it impossible to
remove plugins you don’t need without causing errors, and generally
set a bad precedent for future widget additions.
Now, pretty much all the UI widgets in the jQuery Mobile library are
completely decoupled so they can simply be deleted if not needed for a
particular project. This change allows you to dramatically reduce the
size of the library by only including the specific set of widgets or
features you need, in addition to the handful of required, core files.
While we still plan to do more decoupling and cleanup, the following
files are now decoupled and can safely be removed from the make file
before you do a custom build:
page header/content/footer
collapsible
controlgroup
fieldcontain
fixheaderfooter
button
checkboxradio
select
slider
textinput
links theming
listview
navbar
grid
We will work on a dependency map because a few widgets rely on others
to work. For example, the button markup plugin is called by many of
the widgets above, so it can only be excluded but if you’re not using
any of the widgets that depend on buttons.
We’re still working out our recommendations for mapping plugin
dependencies and decoupling things even further. Ultimately, this will
be surfaced in a download builder tool, so stay tuned!
You can head over to their GIT Repo and just download what you want:
https://github.com/jquery/jquery-mobile/tree/master/js
Not sure if you're just looking for event support, but this worked for me:
<script type="text/javascript" src="js/jquery.mobile.define.js"></script>
<script type="text/javascript" src="js/jquery.mobile.core.js"></script>
<script type="text/javascript" src="js/jquery.mobile.media.js"></script>
<script type="text/javascript" src="js/jquery.mobile.support.js"></script>
<script type="text/javascript" src="js/jquery.mobile.vmouse.js"></script>
<script type="text/javascript" src="js/jquery.mobile.event.js"></script>
When running my web app on my local machine i can ref css/scripts/images using:
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
But when I deployed to my Development server, it wasn't able to find any of my content. After researching the issue everyone suggests using the below method:
<link href="<%=Url.Content("~/Content/Site.css")%>" rel="stylesheet" type="text/css" />
<img src="<%=Url.Content("~/Content/3.png")%>" />
At least now all my content is loaded and works when I push to the development server. However now that I have the server script in there, the "Design" view in Visual Studio doesn't load any styling/etc. I'm wondering if there is an alternative or something I'm missing that perhaps would fix this? Or maybe I'm going about it all wrong? Any input is greatly appreciated.
The suggestion you found is a great way to reference content.
As far as Design View goes, don't sacrifice the elegance of your code just to get Design View. Learn to love Code View. Preview in a browser. In my experience, that workflow really has no major downsides (once you get used to it).
(As an aside, I think most of the developers who like ASP.NET MVC do not use "Design View" in Visual Studio. One of the reasons I love MVC is that it allows me to be picky about the markup. Any kind of designer lies outside that kind of thinking.)
You can always cheat the designer with an atrocity similar to this:
<% if (false) { %>
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<% } %>
<link href="<%=Url.Content("~/Content/Site.css")%>" rel="stylesheet" type="text/css" />
but hey, quite honestly hitting F5 in the browser will give you faster results than waiting for the designer to load (even if your application is hosted on the other end of the world).
Design view is broken? Thats not a bug in your code, thats just the way it is. This is true for ASP.NET MVC and regular ASP.NET
It looks like there's an issue in MVC 2 RC1 if you want to use jQuery.Validate but not the main Microsoft AJAX - which is 25kb even when gzipped.
According to Phil Haack you're supposed to be able to just include these scripts:
<script src="/Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcJQueryValidation.js" type="text/javascript">
Unfortunately in some reorganization they did between Beta and RC - you also now need to include MicrosoftAjax.js which defines the Type prototype functions that are used by MicrosoftMvcJQueryValidation.js (the first line is Type.registerNamespace('Sys.Mvc'); which is defined in MicrosoftAjax.js)
Has anyone already extracted out the necessary code from MicrosoftAjax.js that is needed?
I'll have to do it sooner or later but if anyone has already done it that would help a lot!
Aha!
Looks like MicrosoftMvcValidation.js is NOT the file needed for jQuery.validate.
You need to use the very similarly named MicrosoftMvcJQueryValidation.js. This has no dependency on Microsoft.Ajax.js.
The latest version of MicrosoftMvcJQueryValidation.js is available in the futures download project. It isn't included in the normal download - hence my confusion.
Instead of jumping through hoops to get this working, you might want to look into letting Microsoft/Google serve the AJAX library for you. This would likely give you a speed advantage. And a good chance that the library will already exist on the client's machine.