Thoughts on .Net & Coding
.Net Articles, tutorials, reviews, code and more...
-
Customize HTML5 Validation Messages in ASP.NET MVC
HTML5 allows you to put constraints on the data entered in form fields through several techniques. These techniques include new input types (such as email and url) and attribute such as required and pattern. When these constraints are violated the browser shows an error message callout and the form submission is cancelled. Although this default arrangement works great in many applications, at times you may want to customize the error messages and how they are displayed. This article explains how such a customization can be achieved with the help of a couple of new events and a dash of jQuery code.
-
Utilize HTML5 ContentEditable in ASP.NET MVC to Edit View Content
Usually ASP.NET MVC developers create two separate views for displaying data in read-only and editable form. Although this technique works well, you can utilize a feature of HTML5 to conveniently read as well as edit data on the same view. HTML5 offers contenteditable attribute that magically turns any read-only area of a web page into an editable region. Using contenteditable in combination with some jQuery code you can easily develop a view that toggles between read-only and editable mode.
-
Receiving Data As FormDataCollection in ASP.NET Web API
The Web API actions must follow prescribed signatures in order to work as expected. More often than not this parameter is of a complex type that wraps the actual pieces of data in its properties. This arrangement goes well when you know the exact model being passed by a client. However, this arrangement is of no use when a client is sending arbitrary pieces of data not mapping to any model. Luckily, Web API provides a way to deal with such data. This article discusses just that.
-
Customize View, Partial View and Layout Search Locations in ASP.NET MVC
By default ASP.NET MVC stores all the views associated to a controller inside a sub-folder of Views folder. On the same lines partial views and layout pages are stored inside Shared sub-folder under Views folder. Although this default arrangement works well in most of the cases, at times you may want to deviate from this convention based arrangement and store views, partial views and layouts in some different folder structure. Luckily, you can easily deal with the situation by creating a custom view engine. This article tells you how.
-
Load ASP.NET MVC Partial Views Dynamically Using jQuery
Most of the times ASP.NET MVC views are rendered as a result of user navigating to some action. For example, when a user navigates to /home/index in the browser (either through address bar or through a hyperlink), ASP.NET MVC executes the action method and usually returns a view to the browser. This means each view is rendered as a result of a full GET or POST request. At times, however, you may want to load views dynamically through Ajax. This way you can render contents of a view without full page refresh.
-
Perform List, Insert, Update and Delete in a Single View in ASP.NET MVC
A common way to perform list, insert, update and delete operations in ASP.NET MVC is to create four separate views. The List view forms the launching view where records are displayed and you can choose to Edit, Delete or Insert a record. However, in some cases you may want to perform all these operations in a single view itself. This task can be accomplished using full page postback or using Ajax. This article discusses the former technique.
-
Optimize ASP.NET MVC Views with Bundling and Minification Features
ASP.NET MVC web applications often use client side scripting in one or the other way. Use of JavaScript libraries such as jQuery and frameworks such as AngularJS is quite common these days. Therefore it is important to pay attention to the rendering of the views. Especially, script load time is worth some consideration. Luckily, ASP.NET MVC offers help in the form of bundling and minification features. This article shows how these features can help you optimize the views.
-
Understanding JavaScript Prototypes (and creating your own "$" library)
Many web applications developed today use some or the other JavaScript library or framework. These libraries and frameworks heavily rely on what is known as JavaScript prototypes. Therefore, it would be interesting to any web developer to understand this concept. This short article explains in brief what JavaScript prototypes are and how they form an integral part of many of the popular JavaScript libraries. You also learn to create your own "$" library.
-
Implementing Sorting and Paging in Web API using OData queries
The client displaying data returned by a Web API may want to implement sorting or paging on the data being returned. Although there can be different ways to implement these features, a simple technique is to use OData support offered by the Web API. This article shows how to call a Web API by using a client-side script and also shows how to implement Ajax-driven sorting and paging.
-
Implementing Sorting and Paging in ASP.NET MVC
Displaying records in a table is a very common requirement in many web applications. Such a table also needs facilities such as sorting the data based on a specific column and pagination for the sake of easy navigation and display. Unlike ASP.NET web forms, MVC doesn't have readymade server controls such as GridView to ease your job. One needs to either use a third-party helper or make some custom provision to accomplish this task. This article shows how persistent and bidirectional sorting as well as paging can be implemented in ASP.NET MVC without any external dependencies.