Thoughts on .Net & Coding
.Net Articles, tutorials, reviews, code and more...
-
Pass Multiple Models And Anonymous Types To View in ASP.NET MVC
Developers new to ASP.NET MVC often ask these questions: How do I pass multiple models to a view? How do I pass anonymous objects to a view? This article provides a solution to both of these questions.
-
Store DateTime as UTC and Convert As Per User's Time Zone
Developers often store date and time values in the database that are obtained through DateTime.Now. These values are returned as per server's time zone. In some cases, however, you need to display these values as per end user's time zone. This post discusses one way to deal with the situation.
-
ASP.NET MVC Controller Vs. Web API - 5 Things You Should Know
ASP.NET MVC allows you to expose functionality through action methods. One can also expose the functionality as a Web API. Beginners often find it confusing to decide when to go for an MVC controller driven approach and when to go for a Web API. Here are five main considerations that can be helpful while taking a decision.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.