I have recently learned that it is possible to check the validity of a form using JQuery. Let us say that you have a form with several fields that uses data annotation in validation. Before doing an Ajax call you would want to check if...
Creating custom data annotations in ASP.NET MVC is not really dificult. You just need to follow some steps that should be done, otherwise the data annotation might fail to work, maybe on the client side or on the server side.
Here are...
One of the things that surprised me with the MVC framework is how easy it is to return Json objects from the controller. It is really a one liner and it could not get any simpler.
Let us say you have a Student class and after filling...
One of the new things I have learned lately is that you can pass a model to a partial view when it gets rendered. I knew that I can use strongly-typed partial views and bind them to a model. But I did not know that I can assign specific...
One of the common tasks for web programming is allowing users to download a pdf file. Assuming that you have the means to create a pdf file and put it in memory, you can use the pattern below for downloading it to the user's...
In a previous post, we discussed how to dynamically sort objects using the Dynamic LINQ library. In this post, I will show you how easy it is to page your objects using the built-in LINQ.
These two features are very useful when you are...
Sorting is built-in in the LINQ library, however, you need to use column names and keywords for controlling the direction of the sorting (static).
With the availability of the Dynamic LINQ library, you can now sort using strings...
Similar to the need of rendering a full view into a string, rendering a partial view is not built-in in the ASP.NET MVC 2 framework. The typical uses of this aside from generating pdf is in returning values to ajax calls. Let us say that...
There might come a time when you will need to get a string representation of a view. Currently in the MVC 2 release, this is not built-in. Typical uses of this is in generating pdf files from views. With the view rendered as string, you...
Similar to the need for getting the absolute url of a link, you might want to know the disk path of a web content. Again, this is not present in MVC 2.
You can use the custom HTML helper below to achieve this:
public static string...
There are times when you might need to get the absolute url of content or page in your website. Unfortunately, there are no built-in helpers in MVC 2 for you to do this.
You can use the code below to create a custom HTML Helper that...
It is observed that in the current release of ASP.NET MVC 2, the data annotations do not work when the form is dynamic, like in the case where it is fetched from the server via JQuery. A typical scenario where this occurs is in modal...