DennyDotNet

Awesome ASP.NET C# and other cool coding stuff

About the author

Denny Ferrassoli
Developer at Casting Networks. MCP / .NET
E-mail me Send mail
Add to Technorati Favorites

Recent posts

Recent comments

Authors

Categories

None


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

ScreenCast: MVC, jQuery and REST

So I recently picked up a copy of Camtasia Studio (www.techsmith.com) and wanted to give it a shot by creating my first screen cast.

This screen cast is going to show you how to create an MVC application that uses jQuery (http://www.jquery.com/) to do some AJAX calls against a REST url. You should be familiar with jQuery and the MVC framework but I tried to keep it as simple as possible. The screen cast runs for about 25 minutes - Click the image below to start watching.

Comments, questions and suggestions are welcome...

You can download the sample project here: MVCjQueryREST.zip (41.41 kb)

kick it on DotNetKicks.com

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags: ,
Posted by Denny on Sunday, December 16, 2007 3:41 PM
Permalink | Comments (9) | Post RSSRSS comment feed

Comments

Willie Tilton United States

Friday, December 21, 2007 5:28 AM

Willie Tilton

Pretty cool cast.  Some questions, why didn't you assign the click event via jQuery?  I'm also curious about integrating some type of DAL like SubSonic (using it's built in REST stuff) and seeing what we can do with the ID values with jQuery and seperate view "controls", loading dynamic data from them.  Is this a ton harder to do?  I'm trying to do something similar in Web Forms using jQuery but not coming up with anything so far.

Denny United States

Friday, December 21, 2007 6:20 AM

Denny

Hey Willie. I didn't use unobtrusive javascript (en.wikipedia.org/wiki/Unobtrusive_JavaScript) because I forgot :-X It certainly is better to define the click function via jQuery. For anyone else who isn't familiar with unobtrusive javascript check out the wikipedia page.

I haven't tried using the SubSonic REST templates yet so I'm not sure how to work with the ID values. However there is a great article on using MVC, jQuery and JSON to customize which Controller / View you want to target: weblogs.asp.net/.../...b-application-and-json.aspx

Also, if you get a chance check out LINQ to SQL as a DAL.

Willie Tilton United States

Friday, December 21, 2007 6:30 AM

Willie Tilton

Thanks man, I'll check the link out.  I honestly wasn't sure if you were doing it for some reason.  I'm fairly new to jQuery and while it's great it can get pretty particular about certain things.

Jorge Diaz Tambley Chile

Monday, December 24, 2007 3:03 AM

Jorge Diaz Tambley

Pretty good webcast, the content was very clear and the way you presented it was great.

Hope you create a new one soon.

bonder United States

Saturday, December 29, 2007 6:56 AM

bonder

Hi Denny,

Great screencast!  On a tangential note, I really like your color scheme for text editing.  Can you share them?

Denny United States

Monday, December 31, 2007 7:31 AM

Denny

Hey Bonder, sorry for the late reply (holidays)... I've exported the font/colors and zipped it to the site. You can download it here: www.dennydotnet.com/.../Exported-2007-12-31.zip

Just use the Import feature of Visual Studio.

Jonathan United States

Wednesday, February 13, 2008 3:19 AM

Jonathan

I'm sure you know this already but you can chain those jQuery commands together like this: $('#container').hide('fast').html(data).show('slow');
Probably not the best use for a screencast where people aren't necessarily familiar w/ jQuery though so I can understand why you wouldn't do this.

BTW, congrats!!!

Ben Scheirman United States

Monday, February 18, 2008 1:24 AM

Ben Scheirman

How is the url you specify a "REST URL?"

/home/getdata is not inline with REST ideas.  What you'd more likely have is
/sodas with a specify HTTP verb that specifies whether you're going to GET them all or PUT one on the server or POST an update to one.

Standard MVC (non-REST) urls should be in Noun/verb form, such as /sodas/list

Also, I would suggest to use your view as a user control so you won't get the validation errors with an HTML fragment.  Nothing in your controller would change, just add a user control view with the same name and it will get rendered.

Good stuff, keep up the screencasts.

Denny United States

Monday, February 18, 2008 4:14 AM

Denny

Hi Ben! Thanks for the tips! I certainly see the issue in the implementation of what I called "REST." My original intentions were to implement complete CRUD operations which would have probably adhered to a true REST implementation, like you explained. However I have seen the light and will implement your suggestions in my next installment (i.e. where I will add CRUD operations).

Thanks! I appreciate your feedback!

Comments are closed