Click here to Skip to main content
15,894,017 members
Articles / Web Development / XHTML

Custom controls in ASP.NET MVC

Rate me:
Please Sign up or sign in to vote.
4.76/5 (31 votes)
8 Jan 2009CPOL8 min read 159.6K   2.9K   95  
Control library for rendering custom HTML in ASP.NET MVC applications.
using System;
using System.Web.Mvc;

namespace MvcControls
{
	public static class ModelStateDictionaryExtensions
	{
		public static ModelErrorCollection GetErrors(this ModelStateDictionary modelStateDictionary, string modelName)
		{
			ModelErrorCollection modelErrors = null;

			ModelState modelState;

			if (modelStateDictionary.TryGetValue(modelName, out modelState))
			{
				modelErrors = modelState.Errors;
			}

			return modelErrors;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
Software engineer.

Blog: http://andrewgunn.blogspot.com/
Twitter: andrewgunn

Comments and Discussions