Archives

Archives / 2013 / April
  • Content Negotiation in Web API

    Whenever you access ASP.NET Web API from your client side script (JavaScript / jQuery) by default the data is returned in JSON format. However, in certain cases you lay want to retrieve the data in XML format instead of JSON. On the server side, Web API determinses what data format to use for sending data to the client by doing what is known as Content Negotiation. Simply put, content negotiation is a process by which Web API inspects the incoming request and HTTP headers accompanying the request to figure out what response format(s) the client can understand. Based on this checking Web API sends the output.

  • Using Preprocessor Directives in C#

    C# preprocessor directives are commands that are meant for the C# compiler. Using preprocessor directives you instruct the C# compiler to alter the compilation process in some way. For example you may instruct the C# compiler that a particular block of code be excluded from the compilation process. This article examines several C# preprocessor directives available, with an example of each.

  • Edit GridView data without displaying default Edit, Update and Cancel buttons

    ASP.NET GridView control provides an easy way to edit and update data with the help of CommandField column type. The default CommandField arrangement is such that the Edit, Update and Cancel buttons are displayed in a column. The problem with this design is that the GridView edit column always occupies some screen real estate. Additionally in the edit mode the GridView expands horizontally disturbing the page layout. Luckily, with some easy trick you can render an editable GridView without displaying the default Edit, Update and Cancel buttons. This post shows how.

  • Working with Promises in Windows Store Apps

    To deal with the complexity involved in asynchronous programming, Windows Store apps make use of what is known as a Promise. The implementation of Promises in Windows Store apps is based on Common JS Promises proposal. At code level a promise is an object that represents the result of an asynchronous operation and returns a value at some later time in the future. Promises make it easy to work with asynchronous operations in Windows Store apps. This article discusses what promises are and also shows how to use them in a Windows Store app.

  • Convert GridView Data to CSV using jQuery

    At times you may want to allow the end user to save GridView data into CSV format for further processing (say for opening later in Excel). Doing so using server side code is quite common. However, this requires an extra round trip to the server. You can also convert data from a GridView into CSV using jQuery. This post shows how.

  • Using SimpleMembership in ASP.NET MVC 4

    Features such as membership and role management have been a part of ASP.NET core infrastructure since version 2.0. Developers have been using the default membership provider and role provider in their web applications. However, a common observation is that the default membership and role providers are quite rigid in terms of database schema and the way user information is stored. Luckily, SimpleMembership provides a helping hand in this area. It extends the core membership and role providers in such a way that you can use a custom database table to store user information. This article gives you step by step instructions to configure and use the SimpleMembership in ASP.NET MVC projects.

  • Display a list of audio / video files using HTML5 and GridView

    Recently one of the readers asked this question - How to display a list of audio and video files in ASP.NET web form? Additional requirements were - a) The database contains audio as well as video file URLs. At run time depending on whether a file is audio file or video file appropriate media player should be displayed to the user. b) At a time only one media file should be playing from a given list. This post provides one of the possible solution to the problem.