MVC

MVC DropDownListFor fill on selection change of another dropdown

Binding DropDownListFor from enum, database and some hard coded values in our previous article [MVC dropdown binding best ways][1]. In this article we will try to bind child Dropdown on selection change of parent Dropdown, say Country to State or Sate to City, by using jQuery which will call an action in controller and return JSON for selected id, and with the help of jQuery append values to... By Ali Adravi   On 11 Apr 2015  Viewed: 141,793
  • mvc
  • dropdownlistfor
  • jquery
  • javascript

MVC insert update delete and select records

CRUD (Create, Retrieve, Update and Delete) in MVC. When we start to learn new language, first we try to run an application with “Hello World” and then CRUD functionality. So in this article we will see how to select records from database (with WebGrid, pagination and sort functionality), update a record, add new record and finally delete a record in ASP.Net MVC. Let’s create a simple table... By Ali Adravi   On 17 Aug 2013  Viewed: 95,811
  • mvc
  • asp.net
  • sql server

Search, sort, paging, insert, update and delete with ASP.Net MVC and bootstrap modal popup PART-1

Search, sort, paging, insert, update and delete with ASP.Net MVC and bootstrap modal popup and WebGrid to show records with search, sort and paging feature and in next article we will complete our article by adding insert, update and delete feature with bootstrap modal popup. We are going to use Entity Framework 6 code first model with a very simple table phone. Adding client side sorting and... By Ali Adravi   On 28 Dec 2014  Viewed: 53,015
  • mvc
  • bootstrap
  • webgrid
  • modal-popup
  • asp.net

MVC dropdown binding best ways

To Bind a DropDownListFor or DropDown in asp.net MVC from database, from enum or from hard coded values, most people suggest to add a property in the model with IEnumarable or IList. We can use it but not very helpful because after every postback we will need to fill the list again otherwise it will be null. So using ViewBag is not a bad idea, we will use it in our article. What we will see... By Ali Adravi   On 04 Apr 2015  Viewed: 42,447
  • dropdown
  • dropdownlist
  • dropdownlistfor
  • mvc
  • enum

Search, sort, paging, insert, update and delete with ASP.Net MVC and bootstrap modal popup PART-2

To add insert, update and delete feature we are going to use bootstrap modal popup with a single JavaScript method to open any partial view as a modal popup and one method to post the data from modal, which can work for entire application. First we will add some code to our layout view to dynamically add the partial view in it and JavaScript file, then we will add code only one for add new... By Ali Adravi   On 28 Dec 2014  Viewed: 41,441
  • mvc
  • bootstrap
  • modal-popup
  • asp.net

mvc search page example with code

MVC Searh page with pagination: It’s very easy to create a search page in asp.net but when I try to create the same in MVC I faced many problems, how to create model, how to keep searched values in search controls, pagination, I found myself nowhere, so start searching for some good examples but whatever I found was not quite helpful so try my own. I will explain the same in this... By Ali Adravi   On 25 Aug 2013  Viewed: 34,331
  • mvc
  • search
  • model

Image gallery in asp.net mvc with multiple file and size

Image gallery in asp.net mvc or in any other language can be achieved by using different free JavaScript libraries. What we need for a good image gallery, at least we need images in two sizes to show thumbnail and then the original image on clicking the image. In this article we will write a small method to calculate the new image size and save images in multiple sizes. To upload image we will... By Ali Adravi   On 10 Jan 2015  Viewed: 27,153
  • mvc
  • c#
  • image
  • image-gallery
  • asp.net

MVC display image from database

Uploading image to database is not a normal practice but in some situations we need it, in my [previous blog][1] many people request to write to store the image into database, first of all, I would like to thanks for all those emails and interest in my blogs and site. I am going to change the database structure a little bit but use the same modal to post the data from view to controller which... By Ali Adravi   On 03 Aug 2015  Viewed: 25,126
  • mvc
  • image
  • upload

ng-grid search sort paging with AngularJs WebAPI and MVC ASP.Net

We are going to use ng-grid with feature like searching, sorting and paging of records, we will use paginated data, means pull only as many records as we have to show into our ng-grid. We already discussed about the AngularJS application structure in our previous article see [ASP.Net MVC Web API AngularJS and Bootstrap application structure][3]. We will use Entity Framework and WebAPI to search... By Ali Adravi   On 30 Nov 2014  Viewed: 22,300
  • ng-grid
  • angularjs
  • webapi
  • mvc

Upload files with model data in MVC

Upload multiple files with model data in MVC is really very easy, when I started to test by uploading some files, I though it would be more complicated but it is really not. In my previous post [ASP.Net MVC file upload][1], I promised to post soon about how to upload multiple files. When I was writing I thought why cannot add model data as well at the time of uploading the files. We will... By Ali Adravi   On 04 Jun 2013  Viewed: 22,005
  • mvc
  • file-upload

MVC multiple field search with webgrid - Step 5

First of all we will try for multiple field search with paging and sorting for products by using WebGrid. We will create relationship between products and category table so we can show the category name in grid. To search we need a separate model for search having all the paging, sorting, total records and products. We need full featured page to search records by providing product name, price and... By Ali Adravi   On 22 Mar 2015  Viewed: 20,988
  • mvc
  • webgrid
  • dynamic-order
  • paging
  • sorting

MVC WebGrid Search code with example

MVC webgrid searh page with pagination: There are many benefits of using WebGrid in place of table like paging, sorting and alternate row style etc., in our previous article we see [MVC search page example with code][1] but there we used table to create the structure of gridview which is missing sorting and alternate row functionality. In this article we will use WebGrid and check how easy it is... By Ali Adravi   On 25 Aug 2013  Viewed: 17,344
  • webgrid
  • mvc

MVC EnumDropdownListFor bind with enum example

In MVC we have EnumDropDownListFor which we can directly bind with our any enum, it is very similar to DropDownListFor. In this article we will try to create an enum and use it into our model and see how we can bind and save it into the database. As we know we cannot keep space in the name of emum members so how we can use a clear text into dropdown than the enum members. It is easy we will use... By Ali Adravi   On 15 May 2015  Viewed: 16,803
  • mvc
  • enumdropdownlistfor

ASP.Net MVC upload file with record & validation - Step 6

Uploading file with other model data, validate model & file before uploading by using DataAnnotation is a tricky part because there is no FileFor or any similar control in MVC. So very first question comes in mind, is that possible to use DataAnnotation with file control? Yes, it is very possible. Second question, it this possible with client side validation, even the answer is yes. We know... By Ali Adravi   On 28 Mar 2015  Viewed: 14,293
  • mvc
  • file
  • sql
  • model
  • validation

Razor conditional attribute and formatting

Razor provides all the option to format the data as well as conditional attributes, even it is more powerful than we had earlier in asp.net. In this article we will try to see some commonly used conditional attribute tricks, formatting of data like apply class conditionally, show hide controls, enable and disable the controls. How to use icons as link in WebGrid, add HTML to the column,... By Ali Adravi   On 14 Mar 2015  Viewed: 12,946
  • razor
  • mvc
  • formatting

ASP.Net MVC Web API AngularJS and Bootstrap application structure

Application structure by using ASP.Net MVC, Web API, AngularJs is not complicated but we need to know what NuGet Packages are required and what can make the application easy and speed up the development. In this article we will use MVC 4, Visual Studio 2012, Web API and AngularJS to create a single page application. We will try to use different folders for keeping our controllers, services,... By Ali Adravi   On 17 Nov 2014  Viewed: 9,525
  • angularjs
  • webapi
  • mvc
  • bootstrap
  • asp.net

ASP.Net MVC file upload

How to upload file or image in asp.net mvc is not difficult but is totally different compare to asp.net FileUpload control. If we are asp.net developer and we are new to mvc then we immediately noticed we don’t have server side controls so the FileUpload control as well and our problem start here. Now we start searching how to upload a file if there is no FileUpload control, no problem whatever... By Ali Adravi   On 25 May 2013  Viewed: 7,189
  • mvc
  • asp.net
  • file-upload

MVC jQuery datepicker enable disable dates

Add, enable, disable dates to datepicker control is really more than easy but I found most beginners struggle with it to add datepicker with a control or to enable and disable dates for a particular condition. In this article we will learn how to add datepicker without any calendar icon as well as with calendar icon. Disable dates which are less than today's date, disable dates which are greater... By Ali Adravi   On 15 Mar 2015  Viewed: 6,241
  • jquery
  • datepicker
  • mvc

MVC jquery autocomplete with value and text field

In MVC, autocomplete with jquery is the best way to pull data from database and render according to our requirements, so in this article we will use jquery to show the auto complete text box without any ajax controls. We need a method to get the data from database, a controller method to handle the action and a jquery/javascript function to call the controller method. Note: we will use... By Ali Adravi   On 29 Jun 2013  Viewed: 5,897
  • mvc
  • jquery
  • json
  • auto-complete

MVC model validation for email from database in asp.net

There are many cases where we need to validate the value in controls before submitting to the database, so let's discuss email validation like format, length and existence into database. We will walk through in this article, how to validate entered user email from database, whether email is already exists in database if yes then show error to user that email already taken by some one, if no email... By Ali Adravi   On 05 Jan 2013  Viewed: 5,727
  • mvc
  • asp.net
12