Feeding .NET MVC Views the jQuery UI way - asp.net

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.

Related

Is there something equivalent to PrimeFaces for ASP.NET?

I'm being a ASP.NET developer over years but recently I started to work with some PrimeFaces solutions with JSF 2.0. I haven't nothing to complain about it.
It is worth emphasizing a few points that did ​​me likes the PrimeFaces: many components, easy to use, fully based on jQuery and jQuery UI (which are very important to me) and very focused on web standards (even more important to me).
But there are some cases that I would really want my server-side with ASP.NET. I don't want to start a discussion here about advantages between JSP and ASP.NET, both has many motives to be used.
Well, the standard ASP.NET components aren't jQuery based, aren't themable with jQuery UI Themes, aren't fully based on web standards (a big problem) and the variability is much more simple (there aren't Carousel, Accordion, Captcha, Slider, Spinner, etc, etc, etc).
EDIT
Continuing the saga, the #Raynos answers inspired me to study lighter possibilities, like the suggested manos. But I really would like something a little more automated, at least in the HTML generation for common controls. Someone known working CRUD samples for manos or additional modules supporting this task?
Recalling that the main question is still open anyway: Do you know any UI Framework for ASP.NET based on the same ideas of PrimeFaces, prefered open-source like it is?
I suppose we cannot answer your question with something simple. As showed by other answers, unfortunately we don't have in ASP.NET any UI framework fully web standards based.
You surelly have that choice about not using ASP.NET but another .NET Framework based engine. I really think that ASP.NET MVC would be the more closest to JSF and so to PrimeFaces. But it haven't a large set of builtin controls based on jQuery as you liked on PrimeFaces. Also, if you only used up to now the vanilla ASP.NET, the MVC concept can be very confusing to start through a professional project.
It may be safer to continue with your technology knowledge while learning something totally new. Even so I don't indicate manos to your project, although it shows to be very light and stable. Furthermore, with it you would need to "recreate the wheel" for many tasks that ASP.NET knows to do well within the standards and such.
Based on these arguments, it seems that in your case you (or your team) is so familiar with ASP.NET that your immediate need is to use good tools to improve the shortcomings of ASP.NET on HTML5, web standards and themes. Then you don't need to change everything you knows right now, just improve what you already know (and of course we recommend that you consider these other approaches gradually).
So let a few helpful hints for you:
First read about and download a sample of a good architecture using HTML5, jQuery and jQuery UI. This post covers all those technologies and have the full source code to download.
Also have in mind that you don't need start your project from scratch. There is the great HTML5 BoilerPlate which comes with dozens of good pratices (and a nice Web.config created with many nice ideas). Important note that it's also based on jQuery as you want.
Maybe you already have some incredible themes created for PrimeFaces and you would like to use on your ASP.NET projet. Then remember: to take advantage of the jQuery UI Themes you just needs using class names and DOM hierarchy. If your PrimeFaces Complex DataTable gerenates an incredible HTML which is so beautifull with your CSS, just use the same generated HTML inside a UserControl so you can reuse it around all yours pages without needing rewriting all the HTML.
Also remember that PrimeFaces is opensource and because of it you always can open the sources, read the jQuery codes and reuse what you really think are perfect for you.
Then, finally, there are many tools and approaches to support you enjoy what you've done with PrimeFaces and also enjoy your existing knowledge in ASP.NET. Unfortunately we don't have done something like this to ASP.NET, but maybe what you'll do will be so good that you can publish opensource for everyone?
PrimeFaces for ASP.NET is announced. http://blog.primefaces.org/?p=2128
Sounds like you need ASP.Net MVC instead of ASP.Net Web Forms, this gives you much more control.
You have the asp.net mvc html helpers toolkit, see: http://weblogs.asp.net/gunnarpeipman/archive/2010/08/16/asp-net-mvc-meets-html5.aspx
I'm not aware of great open-source .NET integrated UIs, but Telerik RadControls are themeable (sp?), standards compliant, integrated with ASP.NET, and built with jQuery. They are really great if you have a few hundred dollars to burn.
Otherwise, AjaxControlToolkit is integrated with ASP.NET and open source but I'm not crazy about it. It's not based on jQuery but I think it is standards compliant.
Sadly, the open source communities tend to shy away from .NET (and Microsoft in general).
PrimeFaces For .NET Cancelled
PrimeFaces for ASP.NET WebForms project has been cancelled after two releases and as PrimeTek we have decided not to do further investments. Instead of .NET, our secondary focus will be PrimeUI who is very close to 1.0 release already and can be used with any web framework.
You can check out the PrimeUI library which is:
a collection of rich javascript widgets based on jQuery UI. PrimeUI is a spin-off from the popular JavaServer Faces Component Suite, PrimeFaces.

What technologies were used to create Smartermail by Smartertools and Action Method by Behance?

What technology was used to create the User Interface of "Smartermail" by Smartertools and the User Interface of "Action Method" by Behance?
They both have great user interfaces that expand to fit a full browser window, they are both very repsonsive (especially SmarterMail) and I don't believe they require a plugin?
Are these technologies suitable for ASP.NET MVC based sites?
The forum post referenced by another responder was from over a year ago, and some things have changed since then.
Since SmarterMail 7.x, Telerik was abandoned for most of the user interface controls due to some issues with the weight of the scripts and processing time to render things. Instead, custom versions of controls that render simpler HTML and script were developed to ensure things went quickly. SmarterTools still uses Telerik's radEditor HTML editing control, and the DateTimePicker control in applications, however, since they have shown to be the best option.
Charting is now accomplished through the built-in .Net Charting controls that were added in Microsoft .Net 4.0. We found then to be a suitable replacement for the Nevron Charting controls in most cases, and almost as fast.
SmarterMail does not use MVC as of version 8.x. It could be written as such, but at this point the advantages of rewriting it to be in MVC did not yield a good enough return on investment.
jQuery is the primary method of resizing and adding visual effects, and has proven to be quite effective. Most of the performance problems we ran into were related to resizing, so the order of operations when resizing had to be continually tuned.
ASP.Net AJAX with page methods is used to perform a "keep-alive" function on a regular basis that updates counters, signals the session is still active, and retrieves notifications from the server about new email, etc. Many other page functions use AJAX as well to make the pages feel more responsive and to reduce the amount of data flying around.
Grady Werner (SmarterTools)
Here's a discussion about the technologies used in SmarterMail:
We use components from Telerik for the
Splitters, treeviews, editor, menus,
date/time pickers, panelbars,
tabstrips, and popup windows. With our
own custom skins and a lot of hacks
for efficiency. Though I think someone
at telerik spies on us because every
time we hack in an optimization, they
follow suit in their next version
The grid is our own control. Other
than that we use asp.net ajax and
jquery and thats it.
And because your question was tagged with asp.net-mvc-2, you could use the same controls in your application. Telerik provide controls specifically designed for ASP.NET MVC. And jquery and jquery UI are totally server technology agnostic.

Decision maker question: compare ASP.NET / Ruby / Python on web UI controls

I need to learn a language for writing web applications (not websites!).
After some research in google and stackoverflow I ended up that the choice should fall in:
1) Ruby + Rails
2) Python + Django
3) c# + ASP.NET
For sure even pickng one randomly would not be a bad choice, but my question here is specific to UI controls. I come from the win32 developmenet world, so in my past experience I was in sites like DevExpress and Telerik that sell ASP.NET (or silverlight) controls like advanced grids, scheduling components, treelists...
So ASP.NET is covered, since Ruby/Python for me currently are totally unknown can you please shed some light on the UI side? I mean how in those worlds UI controls are managed? Where to find them?
All is done using libraries like ExtJS or JQuery? How does it work? (it is a newbie question, so forgive the over-simplicistic approach).
Ruby on Rails is a server-side framework that processes HTTP requests and responds with HTML†. It doesn't have any concept of the kind of UI controls that you're referring to.
However, it can integrate with JavaScript frameworks such as ExtJS or jQuery and there are some Rails plugins or RubyGems that make this integration work easier. For example, this Railscast shows an example of using a calendar within a Rails application.
†Usually HTML. It can also respond with XML, JSON, text or whatever you like really.
HTML only provides some "default controls". Such as dropdowns, buttons, hiperlinks and checkboxes.
More elaborated controls such as grids or treelists have to be built on top of the page using a combination of javascript and images. There are several libraries out there for doing so, my favourite one being jquery UI.
Ruby + Rails doesn't include any complex UI elements "out of the box" (just plain controls), but including jquery UI (or any other javascript library) isn't really very difficult.
I don't have much experience with Python and Django, but it is more or less the same history: they don't come with "advanced controls" by default; they just provide the regular html controls.
I have even less experience with ASP.NET. It could very well come with a UI library - you would have to look at it.
I've got a couple other remarks: you might be giving too much importance to UI elements. What differences a web application from a web site is not the fact that it uses this or that control; It's the stuff that happens on the server side. Which is, probably, where you will spend most of your time developing stuff.
With this in mind, I recommend you to re-think your question. Instead of asking yourself "what gives me more UI elements more easily" ask yourself "what gives me an easier time developing the server side".
My answer to that second question is, "probably Ruby on Rails". The amount of things it comes with may not be evident at first, but it enforces lots of good practices - from naming conventions, to testing, to unobstrusive javascript (that one on rails 3.0 mostly). The list just keeps going on. And on top of that, its community is fantastic.
In any case, please note that this is just my opinion and that I'm not very experienced on the other 2 systems - I just gave them some exploratory looks. You should check it with other sources.
If you're already familiar with C# and ASP.NET, why not use that?
Of course if you know Python, the Django docs are a good great place to start. Even if you don't know Python they'll at least give you an idea about what it will take to learn/use Python+Django.
HTH!

Maintainability: jQuery or the Ajax Control Toolkit?

My team is currently working on a substantial update to an existing ASP.NET 3.5 application which uses the Ajax Control Toolkit on virtually every page. We've found that in many cases that its use is unwarranted (clearly a previous developer decided to "Ajaxafy" everything), and a richer - and simpler - experience can be found using jQuery.
We've also found that the AjaxControlToolkit can be a pain to work with frankly in terms of maintainability and performance when you have half a dozen developers working it. We're debating scrapping its use completely, and going with jQuery for the UI experience. We're fortunate to have enough time to do this safely, and every feature we use can be replicated without any problems (AutoComplete, Calendar Control, etc).
It seems Microsoft are siding with jQuery with its addition to Visual Studio lately, and the current Ajax Control Toolkit isn't in ASP MVC (client side files only). Therefore I'm personally siding with jQuery for the moment, as it seems to have a future, while the Control Toolkit's future is a little more cloudy.
However, from a maintainability perspective, how is jQuery to work with?
It's essentially just Javascript, so no plugins required. Are updates stable, and do they often break existing functionality?
We use jquery extensively with asp.net 3.5 and have upgrade jquery and jquery ui about 3 times without a hitch. Both times we have had noticeable speed increases. Maintenance has never been an issue in about 2 years of use with 5 developers.
We find jQuery very readable and enjoyable to code with.
Don't give up on AJAX just yet. Both AJAX and jQuery are useful as long as you're using them to do what they're suited to. I really don't see too much of a difference in maintainability, it's all still code. You need to test new releases/updates before putting them into production; vet any 3rd party code you're integrating into your code base, and make sure that you're not using AJAX/jQuery to pound a square peg into a round hole.
As to the pros/cons of AJAX vs jQuery:
AJAX beats out jQuery when it comes to:
Server-Side integration
CLR Features and Feel
JSON and WCF
jQuery beats out AJAX when it comes to:
Animations
Being Lightweight
DOM Selection
Attribute / CSS Manipulation
The ACT isn't in MVC because the control structure is deeply embedded in the web forms product; most vendors (like Telerik, Component Art etc) are actually writing a separate code-base for MVC because of the complexity of making it work with two frameworks, although Telerik did a good job of it (you can use the web form controls in MVC, though the MVC-specific controls are much nicer to use).
I like JQuery, and for a project, I believe we are going to go Telerik/JQuery and plugins, so that is always a good bet.
Also, the ACT does have a lot of scripts and may not be applicable in all scenarios, but the real issue is adding too much AJAX when it isn't warranted, something that can be a problem with any other framework too.
HTH.
jQuery is tested pretty extensively. I don't remember a break caused by an update, you mileage may vary. They would likely know about any compat problems and warn about them in the release notes or elsewhere.

ASP.NET MVC vs. Webforms: Replacing WebForms Controls

I have read several other posts here, so i get the idea on the pro vs. cons, especially having full control over the rendered html code etc. (in MVC).
My question is regarding the UI controls: In MVC, i will have to write all UI controls myself (or the html equivalent). Now is that not going to be very difficult?
The reason why these 3rd party vendors for asp.net are there is just because of the fact that it is difficult to write UI controls for ASP.NET all by ourselves, and be able to target to all web browsers, and also that we are better off concentrating our time on the business logic rather than spending the whole lot of time writing the UI controls HTML code ourselves.
I understand that this feature gets us the full control over the final html, but is it not counter-productive to do this UI bit ourselves. If it was so easy to write them ourselves, how come these 3-rd party vendors are all living now. We could have done this all by ourselves all these years of WebForms days.
I am sure i am missing something here or being a little stupid, but please enlighten me as to what i am missing in specific regard to the UI bit being written by ourselves.
Just because i get full control over the program by writing in IL code, do we go and do that? We still use C# and things like that - So that theory of "having full control over html" - i am not bought into that idea.
Please help in getting my head around this UI bit.
Other things i understand, about the separation of concern, TDD based development possible with MVC etc.
But why would i go around writing the UI controls all by myself - it is a bit a work isn't it?
The thing is:
If you want to master in web development you have to master HTML + CSS + Javascript
And with WebForms you have to learn the WebForms way to do it, but with MVC you have the power of .Net with the freedom to generate the HTML + CSS + Javascript you want.
Here's a new rant on the subject http://www.charliedigital.com/PermaLink,guid,6dcb0333-9d70-40c7-975b-0ff4011c4661.aspx
Problem is, ASP.NET MVC is much younger product than ASP.NET. For many years 3rd party companies have been developing TONS of reusable components, and I believe that it is only a matter of time before comparable set of controls will be available for ASP.NET MVC.
If you really need very rich GUI with 3rd party controls, and you can't rewrite them in acceptable time - stick with asp.net. Altough in my opinion, MVC gives you tons of power it wouldn't be wise to spend much more time rewriting controls than you can save. If you can live without controls, and like MVC concepts - use MVC, and you'll most certainly see 3rd party solutions as soon as they'll there is growing market (maybe thay've already noticed that, I don't know) for mvc extensions.
I believe that the UI and the user experience are vital to the success of a web app. Making the page intuitive and easy to use, minimizing the amount of navigation the user has to do to get the job done, and providing effective feedback and interactivity can make all the difference between a site that users want to use and one that they avoid.
If you are trying to attract users on a public website, a pleasing appearance and excellent usability are key to building repeat visits.
If you are writing an intranet app to be used by hundreds or thousands of employees all day long -- as I mostly do -- making the UI efficient and easy to use really means a lot to your users.
So, I wouldn't downplay the importance of the UI. It isn't a nuisance. It's a key part of the user experience. I suggest that a web developer should embrace whatever tools and strategies that will get the job done. That often means coding the UI controls yourself. Or working with a teammate who likes doing that part of the work.
I recently refactored a very complex website using ASP.NET + handworked javascript to MVC + jQuery. The complexity of the code was reduced by 50%-75% and became much more testable. I replaced all the complex webcontrols I had to write (with a steep learning curve I had to overcome) with very simple HtmlHelper methods.
Don't forget, when you use custom webcontrols, you are given a very static UI by the control developer. With raw HTML, you can take advantage of styles and ui developed by the whole web industry.
Increased simplicity, decreased development time, testability, flexibility in UI... I don't want to go back.
You also have to remember that ASP.NET MVC is just the first release. I don't think there is intrinsically any reason why you couldn't have the equivalent of server controls to enable certain tasks - remember, there are many server controls that don't generate any mark-up (such as the Repeater, PlaceHolder, ListView). These type of controls could be useful in a future MVC setting, I think.
I believe that ASP.net came around when lots of developers were still used to doing desktop applications and just beginning web development. AT that point in time abstracting the details of the web with controls and post backs was a great way to get people started. At that point we weren't trying to perfect the web, we just wanted to get on it!
Now that the web has matured and we've all slowly learned about html, css, javascript and the likes we want to optimize our websites for our own needs and we don't want to depend on ASP.net Forms controls to control the fine details of our websites.
In summary, I think this is about the natural evolution of many developers from the desktop to the web
I for one, am very thankful that you cannot use ASP.NET controls in MVC.
Controls, as many have already pointed out, are just server side blocks of code that render HTML and javascript on your behalf. Things like a datagrid are great, until someone asks you to make a slight modification, like having a delete confirmation alert, and then it seems impossible to do certain tasks.
The good news is that there are very powerful jQuery tools written to help you. jQgrid is a great grid replacement that does WAY more than the ASP.NET grid...
http://www.trirand.com/blog/
jsTree is a treeview that is fantastic. Again with the jQuery....
http://www.jstree.com/
And the truth is that most things you can do with razor, HTML, javascript and CSS. It's so simple that it's just stupid.
It's hard for people like myself who were web forms developers to grasp MVC and why you should use it because it's so simple. It's difficult to let go of the complexity of conventional ASP.NET. But it feels so good when you do.
And don't mix web forms with MVC. You can do it, but you will wish you hadn't.
Here is the key thing that I think you are missing. When ASP.NET is no longer the MS way of doing things...you will eventually be forced to move on and do something else. I have programmed in perl, ASP classic, then ColdFusion, then PHP, then ASP.NET web forms, then ASP.NET MVC...the only thing that they all have in common is the underlying database, design patterns, best practices for a given set of technology AND...HTML, JavaScript, CSS, and Photoshop.
No one is asking you to learn MVC. No one is telling you to not use WebForms. However, complaining that you have to write a raw UI is not going to get you very far in this industry. You should be learning something new every day...and it sounds like some time spent on HTML and CSS would be a great place to start your focus!
The biggest problem you have with relying on third party controls is when a client asks you to do something that the third party controls don't cover. If you can't replicate their complexity plus the added feature request on your own you are skirting a possible failure in your professional livelihood! You will need to know how to do it all...eventually!
I generally suggest that you embrace new technologies. You don't have to use them...but you should at least know how. This way you will know what the best tool is for any given project.
I've been wondering - what's an equivalent of 'control' from webforms in asp.net mvc? It's not a partial view for sure. What else it can be? Controller + partial views via partial requests?
Maybe i'm dumb, blind or both, but i haven't seen any 'control' for asp.net mvc. Just a lot of code snippets to accomplish one specific thing or another.
I believe that asp.net mvc is quite unfriendly with rapid development. Only way out of this problem - a lot of open source code (like MvcContrib), tutorials, sample applications & most important - slightly smarter developers.
You do not have to replace Webforms controls with something else from MVC. Just mix them - http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx
Well, I was also wondering how to use 3rd party controls in ASP.NET MVC. Obviously, and contrary to some answers here, it had to be possible.
As much time has passed since the question was asked, the industry has evolved. So I've searched and found (but havent' yet tested) solutions such as Telerik Extensions for ASP.NET MVC .
I'm posting this answer here mainly to support other MVC newbees such as myself - Just Google
"asp.net mvc" controls

Resources