Form swapping with ASP.Net MVC 4, jQuery and Ajax

In this screen cast I will demonstrate how swap forms within in a section of your page using jQuery and AJAX.

This technique allows you to make your web sites faster and provide an easier (and better user experience).

Get the source code by clicking here.

ASP MVC3 – Editing records with jQueryUI Dialogs and AjaxForms – Razor Version

This post is in response to the several requests I’ve gotten to provide a Razor version of a sample solution I provided a few months ago on Editing records with jQueryUI Dialogs and AjaxForms, which was originally posted using aspx views. If you haven’t read it or seen the video, please take a look at it first; as most of the concepts will remain the same. .

So this solution is practically unchanged compared to the original, however I did I introduced 2 improvements (which could also apply to the aspx version).

  1. I realized after I did my original post that I was able to get data on the handler function from the ajax form; so I am no longer looking into the response div for my data (which was kind of a hack). Instead I am now using it properly by receiving the data directly.
  2. I use a JsonStandardResponse, which I have been using in my projects succesfully and make things a bit easier. (See my previous post: Json Standard Responses for your Ajax Calls). So the controller action was changed to return JsonResult instead of a regular ActionResult with Content.
Here are the details of the change in the controller:
[HttpPost]
public JsonResult Edit(CarModel model) {
if (ModelState.IsValid)
{
CarModel car = CarRepository.GetCars().Where(c => c.Id == model.Id).FirstOrDefault();
car.Name = model.Name;
car.Description = model.Description;
return Json(JsonResponseFactory.SuccessResponse(car),JsonRequestBehavior.DenyGet);
}
else {
return Json(JsonResponseFactory.ErrorResponse("Please review your form"), 
            JsonRequestBehavior.DenyGet);
}
}

Continue reading “ASP MVC3 – Editing records with jQueryUI Dialogs and AjaxForms – Razor Version”

ASP MVC3 – Editing records with jQueryUI Dialogs and AjaxForms

In this screen cast I will show you a demo of how to use  jQueryUI dialogs and MVC AjaxForms to create a rich and simple experience for users when editing records.

The technique is simple; you dynamically load a partial view into the DIV dialog  . There are a few tricks to wire up the validation, and to identify success over failure. .

Get the source code by clicking here, take a look and let me know what you think.

Update: 

After many requests, I’ve created a Razor version, all interested can read the post here. 

In case you missed it: App_Offline.htm

I recently found out about a featured introduced in ASP.Net 2.0 that makes it pretty easy to take your application offline, which is pretty useful for when you are doing upgrades, releases, etc. I’m not sure how I missed this as it has been out there for at least a couple of years, but still wanted to do a post about it in case other people missed it as well.

Continue reading “In case you missed it: App_Offline.htm”

Notes form Visual Studio 2010 At the Movies event (Part 2)

Well, finally I get to write the rest of my notes on this event. If you haven’t read the first part of the notes, go here https://ricardocovo.wordpress.com/2010/04/26/notes-form-visual-studio-2010-at-the-movies-event-part-1/.

Visual Studio 2010 (again..)

Before we continue with the new topics, let me comment on a couple points I forgot on part one.

Extension Gallery

It is now simpler than ever to extend VS2010 functionality. On the Start Page, you will find a link to the extension gallery where you will be able to download extensions both free and commercial.

I already used it, I was able to find a OpenId template from the gallery, installed it and used it immediately. Continue reading “Notes form Visual Studio 2010 At the Movies event (Part 2)”

Notes form Visual Studio 2010 At the Movies event (Part 1)….

On April 20, I attended the Microsoft Event “Visual Studio 2010 – At the movies”. One of the best events I’ve attended lately (content-wise), which speaks very well of the organizing partner Object Sharp. I took a few notes and wanted to share them with all of you. Here it goes:

Continue reading “Notes form Visual Studio 2010 At the Movies event (Part 1)….”

MS BizSpark – Good move to get Start-ups

Starting a company is a lot of work… and expensive! Usually you gave up a steady income to go an do your own thing, and the expenses and costs can creep up very quickly.

For developers on  Microsoft’s technologies, and in general for most start-up, it was always been hard to come up with the money for the MSDN Subscription that can be up to 6K a year. Company with competitive technologies which are open source, this is a major disadvantage for MS.

On top of this, if you developed your site on microsoft’s technologies, shared hosting was always much  more expensive for licensing issues.

Well, it seems that MS has noticed they are loosing too many start ups and are doing something about it…

Continue reading “MS BizSpark – Good move to get Start-ups”

SpryPhoto – An excellent and affordable image server

As a web developer, it is very common to have the need for an image server. Usually the requirement is pretty straight forward: We need to dynamically re size an image. This is very common when you display thumbnails and regular size pictures in a site.

Personally, I also like to have a single source image; that way, I don’t have to create all the sizes I need before hand. But most importantly, if I need a new size in the future I don’t have to create that new size for all the images I already have.

When working on enterprise environment, people tend consider only solutions by big companies which tend to be pretty expensive. People that can’t afford these solutions try to create the component them selves, which can be very time consuming (if done correctly).

I’ve been u sing Spry Photo for a while (http://www.spryphoto.com/). You can see it in action in http://www.clickclassified.ca and http://www.storybank.com.

Continue reading “SpryPhoto – An excellent and affordable image server”

Tools from MS Real Development 07 – Toronto

On October 29-07, I attended the real development event in Toronto presented by Jean-Luc David. I found this event interesting because it was really targeted at developers; it was mainly all demos, and the best part is that they showcased some interesting tools to help us develop better sites.

Not all of the tools shown where new to me, but they were used in a way made those tools that I was already using even more useful. Important to notice that the majority of the tools are free.

 I plan to present here a summary of all the tools they used, with a bit of description. I believe this will be helpful to the development community that couldn’t attend to the event.
Continue reading “Tools from MS Real Development 07 – Toronto”

C#: Asynchronical Function Calls

As a Web Developer, I’ve frequently have had the need to make asynchronical function calls.

Usually, you need to do async calls when:

  • Function takes a long time to process
  • There is no need to present a response to the user

In this example, I will be showing some code I use on my Facebook Application (Network Trotters) to update the users profiles.

As a quick contextual background, user profiles are cached on Facebook’s side, and periodically I need to clear the cache so it is updated. This action can take a bit of time when you have a high number of users, but it doesn’t really require any response to the user.

There are 3 main things you need to do to create an async call:

  1. Create a delegate with the signature you would like
  2. Implement a Function with the same function as the delegate
  3. Call the delegate

Continue reading “C#: Asynchronical Function Calls”