Monthly Archives: May 2012

How to get notified via email on error in your application

I am presenting here a simple but useful way to get notified via email, when ever an error is happening in your application with out using try catch. I am creating a httpmodule in app_code for notifying errors. Here is the code for the module.

I am using my “EmailSender” utility for sending emails here. You can find that here. Using this method, first you should create a folder “MailTemplates” in your root folder and add a html template file for “ErrorNotification.htm” in that folder. You can get the referance for creating the html email template from here. Now add the following code in EmailSender class

You are almost done. Now we need to add the module to our application’s configuration file. Add the following configuration value to your web.config, inside system.web and system.webserver (for IIS7).

Hurrey, so it is done. Cheers and Happy coding.

How to load a csv file to a data table

Here is a simple and optimized method to load a csv file to a datatable object. I have gone through many situations when we can not store data in a database, instead have to store in an xml or csv file. This method helped managing those situations effectively. Here is the code for accomplishing this.

Here is how we are going to use it

How to track changes in a page using jquery

Let as imagine, we need to show the user a confirmation message when he changed something in a page and tries close the page, how to do it ?. Well, here I am presenting a simple way to do that with jquery.
First step is to add a hidden element in your html code

Assuming that you have added the jquery library already, add the following javascript code in your page

Hurrey, you are done. Now if you changed anything in your page and tries to close your page before it is saved, the page will show a confirmation message. However, if you are saving the data using ajax, do not forget to set the value of “haveChanges” to false after saving. So that was it, cheers and happy coding fellas.