What is best way to use JQuery in Asp.net - asp.net

What is the best way to use jquery in asp.net, should I use controls or write inline or mix of both.
Controls are easier to use and save time and Writing jquery in page give more control but take more time. Not all (I mean commonly used) plugins are supported by controls.
There are many jquery controls available on codeplex. If you use any, then tell me which one and why?

You can use JQuery in your ASP.NET application in the same way as using jQuery in any application. Using jQuery with UserControls is a great way to encapsulate functionality and is definitely advised.
The ones to use very much depend on your requirements, You can have a look at the rating from people at www.jquery.com for some idea on how good they are but would advise testing them yourself to see if they do what you require on the platforms you are building for.

Related

Alternatives to asp.net ajax 4.0 templates

Assuming I'm stuck with asp.net web forms (I'd love to use MVC partial views), are there any good alternatives to asp.net AJAX 4.0 client-side templates?
In other words, is there some way to specify some html, with placeholders for data properties, to which I could then bind a JSON result. Are there any good jQuery plugins to do this?
I ask because based on the results I'm seeing from Google, this library doesn't seem to be widely used—most search results are from 2008-2010. This question seems to confirm that suspicion.
EDIT
I despise answering my own question, but this link (jQuery Templates) seems to me to be the best bet. If anyone else has any input, please post.
Definitely consider jQuery Templates. We use them quite extensively in WebForms with ScriptServices as a data provider. There is a very small learning curve.
Also check out KnockoutJS, which integrates seamlessly.
Adam, coincidentally, I am using JQuery to retrieve some server side data calling Web Services via Ajax and binding the result on the client side. On my particular case, I am only showing data in a tabular manner, so I am using the jquery datatables plugin (which is fantastic, in my opinion; the API is well documented and easy to extend if you need to).
If you need to show data differently, I think you'll need to write quite a good amount of boilerplate javascript code.
EDIT: I just saw your link reagarding Jquery Templates and looks really cool. I didn't know it existed :) Thanks!

Can I use jQuery with my ASP.net website/project?

I want to make my website look spiffy. Should I use jQuery, or what is better suited to be paired with ASP.net?
jQuery works very well with .NET.
I would highly recommend jQuery UI.
http://jqueryui.com/
JQuery compliments .NET quite nicely. Here is a good blog article that should get you started.
I've can say this with confidence - you can use jQuery with .NET with no issues. I do this all the time.
Absolutely. I don't know that it will necessarily make it spiffy as you asked, but it'll certainly ease your programming work.
AJAX will help with the "spiffiness".
You want really spiffy? Look at Silverlight!
Yes, you can definitely use JQuery for ASP.NET apps. Check out an introductory article on how to get started - Getting Started with JQuery
jQuery works as well with ASP.NET as with any other server platform, because it's just a set of client-side scripts. When you consider its daily usage (such as assigning Thread.CurrentThread.CurrentCulture.DateTimeFormat to jQuery calendar) the final code won't look as short and elegant as advertised. The server controls of ASP.NET AJAX have their own bonuses. In short: if you use ASP.NET and not going to change the platform try standard ASP.NET AJAX facility (possibly with AJAX Control Toolkit). Otherwise starting with jQuery can be much better investment.

Feeding .NET MVC Views the jQuery UI way

I've seen a few blog posts and tutorials overviewing mixing in jQuery and the UI elements for Views in a .NET MVC web app. But usually targeted at developers with a comprehensive grasp of the full dev cycle and variations of back/middle tier technologies.
As the front end developer I'm pitching a jQuery-only UI to the back-end dev - he cautions against a non-webforms interface for sake of the code maturity pov.
I'm trying to hit back with "well...it's your pattern ...isn't it elemental to MVC? No logic in the view? I'm reading that to be 'server-side stuff'. You just serialize the properties i'm asking for, or better...let me easily discover what you _can send me...i'll be able to implement the UI via jQuery UI."
So how valid is my position?
Can jQuery's grid be expected to handle at least the bottom 85% of .net's native control (low-to-moderate capacities # of rows)?
How about in-line editing? ...from the grid?
Would working exclusively in Web Services simplify his life at all? and if so, wouldn't that be logical way to build a .net-to-jQuery relationship? - ajax liaisoning twixt server (.net WS methods) and client?
mny thx
--steve...
Don't fight the platform. That way lies pain and suffering.
The MVC view objects are vastly different than asp.net webforms with server controls--you get straight up html. You get jquery and ajax basically for free, with (almost) magic server side ajax call processing.
They are designed to do what you ask. Writing your own jquery ui is reinventing the wheel.
Not only would it be a ton of extra work for no gain. You would be the only developer around trying to do that, and when you needed help, few could offer advice.
If this is an admin interface, and the client has agreed that users must have javascript enabled then I think using javascript to build widgets on the page is a better option than using the asp.net server controls. If however this is a public facing website I would argue that a pure html and css approach is much better, and then use javascript to progressively enhance the page!
Now I dont ever advocate using asp.net server controls, because they spit out poor markup and they are overly complicated to use. Instead I have been using jQuery to do the grunt work and dom querying and traversing. I also dont advocate using jQuery UI because they are missing some very essential widgets, for example no datatable, no treeview etc. I know that there are lots of plugins for jQuery but they are not componentised and therefore each plugin needs to reinvent the wheel to achieve everything it needs. Once you have included all your plugin libraries and css you often end up with a very large page footprint. Also each plugin often has a different home page and documentation that may or may not be up to scratch.
I think that the best UI library is YUI, and you can easily combine it with jQuery. Because each widget is made up from core components the overall weight of download is smaller. Also you have all the documentation in one place with 100's of working examples. Also it means working with the same set of javascript patterns across the board, so with each widget you learn more and more about the library. Hopefully jQuery UI will catch up, but personally I am looking forward to YUI 3 which for me might mean dropping jQuery altogether...
jQuery is a very mature library. It is used by thousands of people across the internet, and I dont think I have ever encountered a bug. YUI is dogfooded by YAHOO so it too is battle hardened.
One thing I did not mention to you is that I am using the default webforms view engine with asp.net mvc. I think it is still the best option as you get intellisense and also Resharper refactoring even searches your views, and the static solution anaylsis can find code errors in your views.
For building my markup I have been using MvcContrib Fluent Html but you could also checkout this article that advocated the DRY principal very well.

jQuery and Asp.Net compatibility

I am trying to use jQuery and Asp.net Ajax library. The jQuery code is solid, I have it working on a separate page. When I incorporate the jQuery code into an existing page that using Asp.net Ajax, the jQuery code does not work.
I think this has something to do with name mangling.
How can I stop asp.net from name mangling or whatever else is going on?
If you're running into major naming issues then leverage QJuery's ability to use almost anything as a selector, including classes. Sure, class lookup isn't as fast as id lookup, but it is far less prone to being mangled by auto-generated code.
Here is a good article detailing How To Work With JQuery in ASP.NET.
Generally, the two frameworks do not interfere with each other. You can run into issues though, since asp.net ajax adds a hole bunch of extra functions to some of the base types like string, int or data.
But usually that is not a problem when only using jquery, but I have had issues with a few plugins that was not written probably, so that might be where your problem is.
With that said, it is hard to give you any concrete help without more information or/and code.
Maybe the two frameworks (jQuery and ASP.Net AJAX) collide in defining some operators like the $.
This old forum post is made by someone facing similar situation.

ASP.NET: Making something similar to Facebook application bar

Is there a built-in control that is close to an application bar at the bottom of Facebook, or is such a function only available through the use of JavaScript/AJAX?
Remember that ASP.NET is server-side, so it controls all processing that takes place before the web page even reaches the user. For functionality like what you're talking about, you need browser-side voodoo like Javascript. So...
Javascript is practically required.
The only other feasible alternative would be Flash.
XML would not be necessary (or even necessarily desirable).
Don't fall into the trap of calling all asynchronous, Javascript-driven behavior "AJAX", because much of it isn't.
I just built something like this in ASP.NET. I recently posted a blog on how to do it. Check out how to build a Facebook Application Bar in ASP.NET.
I used two controls from ComponentOne to help out, the C1Menu control and the C1ToolTip control
I imagine you mean this:
Screenshot: http://screencast.com/t/kqFPArcmYQ
Video: http://screencast.com/t/X6IczIIv
If that's the case, no, it cannot be done with ASP.NET alone. You are correct in assuming it would require javascript, and possibly some AJAX to make those asynchronous calls.
You should look into javascript libraries, such as jQuery & jQuery UI, or MooTools, etc. Those give you a breadth of tools and plugins to create wonderful/dynamic UIs.
http://jquery.com/
(jQuery UI Demos)
http://mootools.net/
(MooTools Demos)
Check out the demos on their pages, to see if those will fit your idea. You can definitely build the core of the menu in ASP.Net, and then use a javascript library to get the dynamic feel that you're looking for.
Hope that helps a little bit.

Resources