Posts

Showing posts with the label MVC

Unity Container implementation in MVC Application

Image
I was reading about the dependency injection and unity container for a while but never get a chance to implement it in real project. Luckily, I got a task to design a small audit application and I thought to use the dependency injection design pattern and unity container to inject the dependencies in Lazy binding manner. I just wanted to share my work with you guys so that you can also take the advantages of unity container. This post will give you the idea how to use the unity container in your future MVC project. Also, I would like to mention that I used the property injection in the example. Lets get started Step 1 – First thing first – prerequisite ·          VS 2015 ·          Unity.MVC (Get it from nuget. I used 5.0.3 version) Step 2 – Create a MVC application Step 3 – Install the Unity.MVC using nugget. After the installation you will see below files get added in project refere...

Post/Send Anonymous object to MVC/WebAPI Action/Method

I was building an MVC application where we need to give the option to the user to maintain the reference/lookup data through the UI. To active this I created different model and partial views. In order to render the partial view I need to create the different action methods and code wise it will be repetition of code. So I finalized to create one action method that take 2 parameter, the first parameter will tell me the type and second parameter will be object Type. Let me show me how I achieve this with an example. Step 1 – Model namespace WebApplication2.Models.Lookup {     public class User     {         public int UserID { get; set; }         public string UserCode { get; set; }         public string FirstName { get; set; }         public string LastName { get; set; }    ...

Add-Edit-Delete-Duplicate rows in HTML table using AngularJS, jQuery and MVC

Image
My client asked me to build the screen that will allow users to add/modify/delete/duplicate records and it should be in tabular format. In this post I am going to use MVC, angularJS, jQuery and HTML technologies to achieve this. Lest get starts Screen mock-up Add Delete/Edit/Duplicate Update Step – 1 CDN for jQuery , jQuery min & angularJS Step -2 HTML Code < script lang ="javascript" type ="text/javascript">     var baseURL = ' @ Url.Action( "Index" ) ' + "/" ; </ script > < div style =" display : none ; color : red" id ="errContainer">     < div class ="span12" id ="divMessage"></ div > </ div > < table id ="tblFutureBulkUpload" style =" font-size : 12px ; padding-left : 5px ; border-color : Black ; border-width : 1px ; border-style : solid ; border-collapse : collapse...