Contents tagged with ASP.NET

  • Utilize HTML5 DataList and jQuery Ajax to Create Autocomplete in ASP.NET MVC

    In data entry forms involving textboxes with predictable values one can use autocomplete to assist user pick an existing value. HTML5 introduces datalist element that can come handy while implementing autocomplete. The datalist element holds a list of options and can be attached with a textbox using list attribute. By adding a bit of jQuery Ajax you can dynamically populate the options in a datalist. This article shows you how to do just that.

    Read more...

  • Use XMLHttpRequest to Call ASP.NET Web API

    Most of the times developers use jQuery $.ajax() to call ASP.NET Web API from the client side script. At times, however, you may need to plain JavaScript to invoke the Web API. Luckily, calling a Web API using XMLHttpRequest object and plain JavaScript is not too difficult. This article discusses how that can be done with a sample Customer Web API.

    Read 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.

    Read more...

  • 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.

    Read more...

  • 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.

    Read more...

  • 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.

    Read more...

  • 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.

    Read more...

  • 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.

    Read more...

  • 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.

    Read more...

  • 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.

    Read more...