I came across an interesting compiler error message when working on an MVC3 Razor view the other day. I needed to bind model data from a type in the .NET System.DirectoryServices.AccountManagement namespace but received the following error when the View rendered. Compiler Error Message: CS0012: The type ‘System.DirectoryServices.AccountManagement.ContextType’ is defined in an assembly that is not referenced.
I have been working recently with ASP.NET MVC 3 and the Razor view engine. For part of the work I’m doing, I need to send some content to the browser based upon certain conditions. I described a couple of ways to do this before in this post and this post and I wanted to share
I posted recently about sending raw unencoded HTML to the client using the Html.Raw() method with MVC 3 and the Razor view engine. I wanted to extend a bit on that post regarding the magic underlying the Html.Raw() method, the HtmlString class in the System.Web namespace of the .NET framework class library. You can use the
I’m working on an MVC Razor project and need to output some raw HTML to disable an HTML text box if the text box is populated with a value. I realized, though, that my initial attempt didn’t render quite the output I expected. My original code to output the disabled=”disabled” attribute (gotta love XHTML compliance!) was
Our software products display a licensing message at the top of the page if the software is in an evaluation/trial phase or if the software license is not valid. To insert the message into the page using MVC 3 and the Razor view engine, we use a simple, elegant method to add content in a
Many times we have areas of an MVC Razor view that displays based upon some condition. For example, we may want show a placeholder message if we have a blank string. In this example, we use the C# ternary/conditional operator to test the message length and display a placeholder message if the original message has