Tag: C#

  • Error intercepting in MVC when saving data

    I have seen many times in MVC the following code,when doing a post and saving data : Why is not good ? I will do a simple example : if some error occurs on the database level ( such as simple unique index on a name column ) or even some error occurs whenestablishing the…

  • Find the Error

    This code was written by me,in a late night moment,when copy paste seems the best option It started this way : So far,nothing special. Just open the url,read into an XML,return first nodes. Then I wanted more – next nodes. Nothing easier – why bother with recursion or proper variable names ? Just copy and…

  • C# quiz

    Fast small quiz for sunny afternoon : What is writing at the console those lines : ( please do not use a compiler) :

  • ASP.NET MVC editing fast a property

    There are some moments when you want to fast edit a property ( like a status or a name) and you do not want to load the entire “Edit” form for this.More,you are in an edit formula and do not want to add a form. So here is the solution in ASP.NET MVC  with jquery-1.4.2.min,jquery-ui-1.8.1.custom.min…

  • Asp.NET MVC and DOS – re-using the ViewModels

    (Please read first : http://msprogrammer.serviciipeweb.ro/2010/03/29/asp-net-mvc-orm-and-viewmodels/ ) One of the biggest challenges in programming was write once- GUI everywhere ( Ok,ORM impedance mismatch is another story) I mean by that re-using the logic from an application in another application. ASP.NET MVC,with the commitment to strongly viewmodels,make me think that it will be now easier to transfer…

  • EF,automatic history of table and T4 files (TT files)

    Usually the data of the tables should be tracking for who modified it. Think about inserting/updating/deleting an employee :   you must know who did those actions and when. So you create another table,identically as structure,and you add another 3 fields,such as [ModifiedDate](when),[ModifiedBy](who),[ModifiedType] (what : insert,update,delete). There are several methods to do it : from database…

  • file helpers

    More than one time you need to let users / application import bulk data in your system . I have had many cases  – data is old data from old software,that is exported in some text files,usually csv. In order to import fast the data,I used FileHelpers from http://www.filehelpers.com/ Let’s say you have the following…

  • MVC Helper Templates

    In my experiences with MVC I have some utilities to share . Some of them are : DateTime fields Numeric fields Watermark Dropdownlist more! Please see the project and give feedback MvcHelperApplication

  • Caching in .NET

    In every application you have some data that is more read-more,write-once or twice. For example you can have the list of Cities of a country,the list of Countries of the world or list of exchange currency. This data is modified rarely. Also,you can have data that is not very sensitive to be real-time,such as the…

  • Save settings – with a class that reads from or saves to app.config or web.config

    Step 1: Add reference to System.Configuration Step 2 :Derive your class from ConfigurationSection Step 3 : Put your values to be retrieved with ConfigurationProperty attribute Step 4: add a section to your config file and an entry Step 5 : read with ConfigurationManager.GetSection and convert to your class Download code See video