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: 169,435
  • 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: 106,155
  • 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: 60,884
  • mvc
  • bootstrap
  • webgrid
  • modal-popup
  • asp.net

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: 49,885
  • mvc
  • bootstrap
  • 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: 47,369
  • dropdown
  • dropdownlist
  • dropdownlistfor
  • mvc
  • enum

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: 40,270
  • 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: 35,852
  • 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: 32,371
  • mvc
  • image
  • upload

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: 27,105
  • mvc
  • enumdropdownlistfor

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: 26,645
  • mvc
  • webgrid
  • dynamic-order
  • paging
  • sorting

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: 25,607
  • mvc
  • file-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: 23,767
  • ng-grid
  • angularjs
  • webapi
  • mvc

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: 20,891
  • razor
  • mvc
  • formatting

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: 19,555
  • webgrid
  • mvc

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: 18,087
  • mvc
  • file
  • sql
  • model
  • validation

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: 10,389
  • jquery
  • datepicker
  • mvc

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: 10,051
  • angularjs
  • webapi
  • mvc
  • bootstrap
  • asp.net

Add calendar to textbox in MVC in 2 minute

Adding calendar with a text box for new MVC developer is not so easy, I always found in my team people struggle to add a calendar with a text box, while it is as easy as jut to add one line of code and done. It’s true, when first time I try to add a calendar with a text box I also searched many website, read blogs and found, I need to add many jquery files from different locations before using... By Ali Adravi   On 03 Feb 2013  Viewed: 8,291
  • mvc

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: 8,103
  • mvc
  • asp.net
  • file-upload

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: 7,110
  • mvc
  • asp.net
12