Allow Html Attribute Not Found [AllowHtml] - asp.net-mvc-3

Can anyone tell me what I need to include besides System.ComponentModel.DataAnnotations to get [AllowHtml] to be recognized? When I add the attribute to a property it tells me the following compiler error:
"The type or namespace name 'AllowHtml' could not be found (are you missing a using directive or an assembly reference?)"
I need to allow html to my field and cannot continue until I get this working. Any help would be greatly appreciated!
Thanks...

As far as I can tell, [AllowHtml] belongs to the System.Web.Mvc namespace.
http://msdn.microsoft.com/en-us/library/system.web.mvc.allowhtmlattribute(v=vs.98).aspx

I had this same issue and took me a while to realise that I was referencing system.web.mvc v2 not v4, so make sure you check the version.
FYI, I had my models stored in a separate project

Related

Are you missing reference?

I am upgrading MOSS2007 solution to SP2013. Everything is fine When I am building the solution at that time it is building successgully.
But when I am trying to publish the solution at that time it is throwing following error:
The type or namespace name 'xxx' does not exist in the namespace 'xxx' (are you missing an assembly reference?)
I have tried many things but no luck.
Is there any solution for this error?
When you have created your solution you may find that you have built the solution on a environment where a certain DLL exists.
Realistically what you need to do is look at your error message and look in to what DLL contains the namespace that the error is giving you the error and check that the DLL exists on all Web servers, Possibly app server(depending on farm set up)
Cheers
Truez

XmlDocument does not exist in current context

I referenced System.Xml in my code, but XmlDocument still does not show up. Whenever I try to use it, it tells me:
Error: The type or namespace name 'XmlDocument' could not be found (are you missing a
using directive or an assembly reference?)
I saw this link that seemed pretty helpful; unfortunately, I am using a Windows Apps template, and it does not allow me to remove or add references, and I am sure that I am not using Silverlight. I am using Visual Studio 2013, with .NET 4.5. Any help is appreciated.
Edit: I am trying to make a background task. This is how I am using it:
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
I got it: the library had been changed or something, so XmlDocument is no longer under System.Xml.
It is now under Windows.Data.Xml.Dom.
This worked:
using Windows.Data.Xml.Dom;

Error building DataAnnotationsModelBinder project to get the Microsoft.Web.Mvc.DataAnnotations.dll

I am refering to the "Validation with Data Annotations tutorial" here http://www.asp.net/mvc/tutorials/older-versions/models-(data)/validation-with-the-data-annotation-validators-cs for my database first MVC3 project. I downloaded the DataAnnotationsModelBinder project but having difficulty building it. It throws following errors:
Error 1 'System.Web.Mvc.IValueProvider' does not contain a definition for 'DoesAnyKeyHavePrefix' and no extension method 'DoesAnyKeyHavePrefix' accepting a first argument of type 'System.Web.Mvc.IValueProvider' could be found (are you missing a using directive or an assembly reference?) C:\XYZ\DataAnnotationsModelBinder\src\DataAnnotationsModelBinder.cs 47 17 Microsoft.Web.Mvc.DataAnnotations
Error 2 Metadata file 'C:\XYZ\DataAnnotationsModelBinder\src\bin\Debug\Microsoft.Web.Mvc.DataAnnotations.dll' could not be found Microsoft.Web.Mvc.DataAnnotations.Tests
Am I missing anything? I tried using VS2008 as well as VS 2010.
Please help.
I'm assuming that you have some missing references, so you need to include the missing references in the project.
You can do this by right clicking the references folder and add them manually. (see image)
Refrences - image
You should not use the DataAnnotationsModelBinder with MVC3. The DefaultModelBinder class already contains all of the logic that was present in the DataAnnotationsModelBinder sample you have linked to.
You probably need to add a reference to System.Web.Mvc 1.0 instead of what you're got at the moment.

Combres, compress and combine .js and .css files

I'm trying to add the following to my ASP.Net solution. I installed it using the nuget package "Install-Package Combres.Mvc"
so far I'm not having the best luck with it as I keep getting the following error
'System.Web.Mvc.HtmlHelper' does not contain a definition for 'Combres' and no extension method 'Combres' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
I also followed the advice of this link... and got same error:/
I'd like to make use of some compression & combination tool/framework so I'm hoping someone has any experience with this
I scrapped the whole combress/casette route after a few failed attempts. I read up a bit and saw that Asp.Net MVC 4 supports bundles/combining & compressing natievly. Which worked quite well for me.
Do you have
<%# Import Namespace="Combres" %>
On the top of the page to include the Combres namespace?
For more information (and the Razor syntax) you can also look at: http://combres.codeplex.com/wikipage?title=5-Minute%20Quick%20Start&referringTitle=Home

External References not referenced in Razor View

I am working with MVC3 with razor view.
I am trying to use a model from different project than the mvc3 project,
for same its report compilation error as
CS0246: The type or namespace name 'MyNameSpace' could not be found (are you missing a using directive or an assembly reference?)
as answered in some other posts, I tried to add #using directive or editing web.config in Views folder, but it is still not working.
Could somebody please suggest.
I was missing a assembly to my project. Seems adding the reference wasn't enough.
Correct, adding the reference wouldn't be enough. It needs to be added as an assembly to the project, or the compiler won't be able to find the library.

Resources