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.

Financial Functions in .Net (C#)

I recently worked on a project where I had to perform financial calculations. The main project requirements where provided on an Excel and because of the sensitivity of the calculations(mortgage payments), I had to keep within 1cent accuracy.

After reviewing the needed calculations, my main issue was the NPV (Net Present Value); although I am familiar with the formula and applications of NPV, I was not sure of the exact implementation in Excel.

So, I jumped to Google to see if there was any implementations and found the Excel Financial Functions for .Net: “… a .NET library that provides the full set of financial functions from Excel.”.

Great! BUT. The library is actually implemented in F# and only the source code is provided, no compiled version…. No problem, since all .Net languages compile into IL (Intermediate Language), all I needed to do was to compile the F# project and then reference it on my C# one.

After I add ed the Financial.dll reference to my project (compiled version included in the provided source code), I am ready to use it on my code, however, note that the following reference is required:

using

System.Numeric;

 

With the reference in place, I can now use the NPV function as follow:

Financials

Comparing the signature of the NPV function on Financial.dll to excel, we can see they are virtually the same:

Financials-Excel

And even though I have shown mainly the NPV usage, this library contains implementation pretty much all financial functions in Excel (Complete List).

There you have it; if you ever have a project where you need to use Excel functions, you can refer t the Excel Financial Functions for .Net library; you can use the compiled library provided on this example, but I recommend reviewing the library page regularly to check for updates.

Hope this helps!

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.Net MVC: Using Json Standard Responses for your Ajax Calls

For the past couple of years, after we started our move towards ASP.Net MVC, we have been using more and more ajax to enrich our user interface and we love it.

At the begining we use to send our responses as simple strings (true/false) or very customized Json responses. However, for the past year or so we’ve been using Standard Json Responses and it has been working great. I’ve passed this idea to a couple of friends and everyone seems to like it so here it is.

Objective & Advantages

The objective will be to have standard Json Responses to our AJAX calls that we can easily re-use accross our application, independent of what action or what objects we are working with… And by having and standard responses, we can have a standard way to handle them.

Download the Code
Continue reading “ASP.Net MVC: Using Json Standard Responses for your Ajax Calls”

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”

.Net (c#) Oodle API wrapper

I recently had the need to interact with Oodle as a way to feed a classified site.

I was suprise to see that while they had php and java libraries/samples already available, but they did not have a .Net one. I searched on their forums and on the web and did not find a library I could use.

Since I had to interact with the api, I decided to make a library, and publish it as an open source component so other developers can use it.

 You can find the library at: http://www.codeplex.com/oodlenet; all the references, source code & samples are included in the workspace.

 I hope this helps!