Validation of Entity with Entity Framework is a tricky way, but it is really simple. In this article we will try to understand how easily we can add the validation with any entity created by Entity Framework with database first approach by using partial classes and pure DataAnnotation. We will not use any if.. else... or switch... case statement to validate different property. It will work with... By Ali Adravi On 08 Jul 2018 Viewed: 2,756
Multiple submit button in ASP.Net MVC is the common and mostly asked question in interview. In this article we will try to see different ways to use the Multiple submit button in a form and what is the best way to use multiple submit button. What we are going to try: 1. HTML5 FormAction and FormMethod attribute in submit buttons 2. Multiple Submit Buttons With Action Selector Attribute 3.... By Ali Adravi On 08 Oct 2017 Viewed: 6,837
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,038
**Introduction** When creating a website, developers find it challenging to implement a design that works on multiple devices, this included desktops, tablets and mobile devices. EPiServer 7 includes a new feature known as Display Channels. Display Channels allow us to control the rendering of the web pages depending on whether the request is from a mobile device or a standard device. When... By Nikunj Bhanushali On 26 May 2015 Viewed: 1,088
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: 26,850
When we look around in today's world, what we see is devices all around. Devices from mobiles to tablets to computers surround us and now the world is talking about internet of things. IOT means communicating between devices where each device will provide some relevant information to other so as to provide a customer with highest level of service. Example can be a Phone providing information... By Nikunj Bhanushali On 01 May 2015 Viewed: 943
To post from different buttons on a single MVC page to different action methods, we need some extra code. We need to create an attribute class by inheriting ActionNameSelectorAttribute and override IsValidName method. We will use the button name to call any particular action on the basis of button name. It looks some thing very difficult but in reality it is more than easy. Let's creat our... By Ali Adravi On 26 Apr 2015 Viewed: 4,112
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: 168,729
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,180
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: 17,903
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,498
CRUD functionality is the basic of learning of any language which we will see in this article and we will see how easy it is with asp.net MVC. We already seen, how we created the listing page without writing a single line of HTML. Same we will do for insert, update and delete by using the wizard. We will not write a single line of code but use the wizard to create controller action methods and... By Ali Adravi On 21 Mar 2015 Viewed: 4,573
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,207
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,431
In MVC, Entity Framework Code First Model is good fit and easy to use. In this case we don't need to create our model separately. Whatever the model we created in our previous article is enough to create the table for category which we are going to achieve in this article and maney more. We will learn how to use Entity Framework with code first, how to decorate properties of table, property data... By Ali Adravi On 28 Feb 2015 Viewed: 2,903
In this article we will learn to create model, controller and finally we will add view to render the list of categories by using list template. First we will try to render the list of hard coded values then in next article we will use Empty Framework to save data into database and show data from database. But for now we need to focus how we can create model, controller and view. so add a new... By Ali Adravi On 24 Feb 2015 Viewed: 1,748
Learning asp.net mvc is really easy which we will realize during our articles. We will start from the very beginning to create a hello world application an application using insert, update, delete features and then try to give the option to sell them by using shopping cart at the end of the article. If you already know the asp.net then it's good and if not then it's best, because in MVC, we... By Ali Adravi On 21 Feb 2015 Viewed: 1,529
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,484
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,428
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,484