Thoughts on .Net & Coding

.Net Articles, tutorials, reviews, code and more...

  • Show Validation Messages Containing Images in ASP.NET MVC

    ASP.NET MVC offers HTML helpers for displaying field level validation error messages as well as validation summary. However, these validation messages are displayed as a plain string. There is no inbuilt way to include images of HTML markup with the output of the validation helpers. In this article I will show how to overcome this limitation using two techniques so that you can display images along with the validation messages.

    Read more...

  • Updated : Creating Wizard in ASP.NET MVC (Part 3 - jQuery)

    In Part 1 and Part 2 of this article series you developed a wizard in an ASP.NET MVC application using full page postback and Ajax helper respectively. In this final part of this series you will develop a client side wizard using jQuery. The navigation between various wizard steps (Next, Previous) happens without any postback (neither full nor partial). The only step that causes form submission to the server is clicking on the Finish wizard button.

    Read more...

  • Updated : Creating Wizard in ASP.NET MVC (Part 2 - Ajax Helper)

    In Part 1 of this article series you developed a wizard in an ASP.NET MVC application. Although the wizard developed in Part 1 works as expected it has one shortcoming. It causes full page postback whenever you click on Previous or Next button. This behavior may not pose much problem if a wizard has only a few steps. However, if a wizard has many steps and each step accepts many entries then full page postback can deteriorate the user experience. To overcome this shortcoming you can add Ajax to the wizard so that only the form is posted to the server. In this part of the series you will convert the application developed in Part 1 to use Ajax.

    Read more...

  • Updated : Creating Wizard in ASP.NET MVC (Part 1 - Full Postback)

    At times you want to accept user input in your web applications by presenting them with a wizard driven user interface. A wizard driven user interface allows you to logically divide and group pieces of information so that user can fill them up easily in step-by-step manner. While creating a wizard is easy in ASP.NET Web Forms applications, you need to implement it yourself in ASP.NET MVC applications. There are more than one approaches to creating a wizard in ASP.NET MVC and this article shows one of them. In Part 1 of this article you will develop a wizard that stores its data in ASP.NET Session and the wizard works on traditional form submission.

    Read more...

  • Validate Model Programmatically in ASP.NET MVC

    ASP.NET model binding framework takes care of validating a model based on data annotation validations. This works well when a model is being bound with request data. However, at times you may need to create and fill a model programmatically. In such cases, although the model properties are decorated with data annotation validators, they won't validate the data because they are not invoked at all. Luckily, ASP.NET MVC allows you to validate a model object via code. This article shows how.

    Read more...

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