Tag Archives

ASP.NET MVC3 Razor Error CS0012: The type is defined in an assembly that is not referenced

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.

Comments Off on ASP.NET MVC3 Razor Error CS0012: The type is defined in an assembly that is not referenced

Injecting Conditional HTML and Content Blocks with ASP.NET MVC Razor

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

Comments Off on Injecting Conditional HTML and Content Blocks with ASP.NET MVC Razor

Use the .NET HtmlString Class to Output Raw HTML

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

MVC Razor Tip: Output Raw Unencoded HTML

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

ASP.NET MVC Razor and Ternary/Conditional Operators or Other Compound Expressions

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

Comments Off on ASP.NET MVC Razor and Ternary/Conditional Operators or Other Compound Expressions
Sign in
classic
Forgot password?
×
Sign up

(*) Required fields

I agree with OptimaSales Terms & Privacy Policy

×