Auto Complete TextBox Using jQuery and ASP.NET MVC

Here we will see how to use JQuery autocomplete functionality in ASP.NET MVC. Application is going to have two entities [employee and department]. On typing names of employee in text box a auto-generated list of names starting with the search text would appear and on clicking any of the name from list the corresponding department and employee name will be shown on page.

Following are the steps to be followed:

Step 1) Create a new project [ASP.NET MVC4 Web Application] and provide the appropriate name [Ex AutoCompleteMVC]. Choose MVC empty application option and click on OK.

Step 2) Create Model Classes

Go to Model folder and right click to add class [Employee.cs] and [Department.cs].

[Employee.cs]

 public class Employee  
 {  
    public int Empid { get; set; }  
    public string Name { get; set; }          
    public int Deptid { get; set; }  
 }  

[Department.cs]

 public class Department  
 {  
    public int Deptid { get; set; }      
    public string Name { get; set; }  
 }  

Step 3) Create a data repository which will have a static list of employees and corresponding departments. [DataLibrary.cs]

 public static class DataLibrary  
 {  
   public static List<Employee> employees  
   {  
     get  
     {  
        return new List<Employee>{  
                      new Employee{Empid=1,Name="Aakash",Deptid=1},  
                      new Employee{Empid=2,Name="Ashwin",Deptid=1},  
                      new Employee{Empid=3,Name="Jorge",Deptid=1},  
                      new Employee{Empid=4,Name="Dilip",Deptid=6},  
                      new Employee{Empid=5,Name="Bihal",Deptid=5},  
                      new Employee{Empid=6,Name="Suresh",Deptid=4},  
                      new Employee{Empid=7,Name="Taylor",Deptid=2},  
                      new Employee{Empid=8,Name="Sedan",Deptid=3},  
                      new Employee{Empid=9,Name="Reena",Deptid=2},  
                      new Employee{Empid=10,Name="Anthony",Deptid=1},  
                      new Employee{Empid=11,Name="Mike",Deptid=2},  
                      new Employee{Empid=12,Name="Jones",Deptid=1}  
                      };  
      }  
    }  
    public static List<Department> departments  
    {  
      get  
      {  
        return new List<Department>{  
                      new Department{Deptid=1,Name="Sales"},  
                      new Department{Deptid=2,Name="Financial"},  
                      new Department{Deptid=3,Name="Marketing"},  
                      new Department{Deptid=4,Name="HR"},  
                      new Department{Deptid=5,Name="Accounts"},  
                      new Department{Deptid=6,Name="Labour"}  
                      };  
      }  
    }  
  }  

Continue reading Auto Complete TextBox Using jQuery and ASP.NET MVC

FIX for Wrapper assembly for type library “MSHTML” cannot be found after Windows 10 upgrade.

Here we will see how to resolve an issue that comes after you have upgraded to Windows 10. After upgrading the system visual studio started showing errors that Metadata file .dll could not be found. After re-building, re-starting the solution as well as changing the references nothing changed and the errors still appeared. If you closely look at the Build failed errors you will find the below para.

C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(2234,5): warning MSB3283: Cannot find wrapper assembly for type library “MSHTML”. Verify that (1) the COM component is registered correctly and (2) your target platform is the same as the bitness of the COM component. For example, if the COM component is 32-bit, your target platform must not be 64-bit.

Now this is very the problem is. If you check your references you will find an yellow warning mark to MSHTML. If you check this with your windows 8.1 machine it will be pointing to an ActiveX control that was registered from a file in GAC.

Continue reading FIX for Wrapper assembly for type library “MSHTML” cannot be found after Windows 10 upgrade.