How to upload file in ASP.Net MVC

This post is about upload file to server using ASP.Net MVC 4. First you need to modify the controller to accept the posted file along with the model. So you can modify it like this. [HttpPost] public ActionResult UploadImage(Student student, HttpPostedFileBase image) { var imageFile = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(image.FileName)); image.SaveAs(imageFile); return...


Problem with Internet Explorer and JSONResult in MVC

While working with the ASP.Net MVC project, one of my QA team member reported a strange issue, while uploading a file, Internet Explorer 9, showing a download file dialog like this. And the controller action is similar like this. [HttpPost, Authorize] public JsonResult Upload(FormCollection collection) { return Json("Uploaded successfully"); }...


How to integrate JQuery UI Datepicker in MVC

This post is about integrating JQuery UI DatePicker in MVC 4. First you need to modify the _layout.cshtml. Because by defualt, it won’t include required references for JQuery UI. You need to include both CSS and JS for JQuery UI references. So the modified _layout.cshtml will look like this. <!DOCTYPE...


Loading partial view on Ajax.Actionlink click

While working on an MVC project, I had to create few partial views and load them dynamically using Ajax. Here is the code snippet for the same. Controller method public ActionResult ShowMenu() { return PartialView("_SimpleMenu"); } In this I am returning the Partial View in the controller method. And here...


How to get code coverage in javascript

Long back I did some posts on getting code coverage in C#. And one of my previous posts was about implementing TDD in JavaScript. This post is about getting JavaScript code coverage. In computer science, code coverage is a measure used to describe the degree to which the source code...


How to write an Extension for Google Chrome

This post is about creating simple google chrome extension, which will help you to find Malayalam meanings of selected word. The very first thing we’ll need to create is a manifest file named manifest.json. The manifest is nothing more than a JSON-formatted table of contents, containing properties like your extension’s...


Test-driven development in Javascript

Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally...