Sometimes there are errors when you build in ASP.NET MVC that just make you want to shoot your own computer! You resist the urge of course (I hope), but the desire is still there! While I was creating an extension helper in ASP.NET MVC using Visual Studio 2010, I came across this error:
How To Solve System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
Ummm.....NO I am NOT missing a using directive or assembly reference - thank you very much! Well actually I was - LOL. I'm using MVC2. It seems that it wants an additional reference to reference RenderPartial now.
Here is a list of the usings I was using
(notice that wording - "usings I was using" - that makes me laugh - I crack myself up sometimes!) -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web;
using System.Reflection;
The using statements above SHOULD be enough to allow me to use RenderPartial. Unfortunately, I had to add ONE MORE using statement to make it work -
using System.Web.Mvc.Html;
That solved the issue! Why does Microsoft change little things like this? Do they do it just to drive people crazy?
Smooches,
Kila
PROBLEM:
How To Solve System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial' and no extension method 'RenderPartial' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
SOLUTION:
Make sure you are referencing MVC in your web.config, make sure you have a mvc using statements listed above in your file and make sure you add the following item to that list of using statements.
using System.Web.Mvc.Html;
This blog is for all Microsoft & .net lovers who may find themselves in need of help or information once in a while. We all have questions and we all need to know more than we know right now. When I come across things that I think may be useful, I post it. When I have something to say that I think is important, which is everything, I post it. All of my C#, ASP.NET, VB, AJAX & programming friends around the world are welcome to the info in my blog - Ramblings Of A Crazy DotNet Woman!
Subscribe to:
Post Comments (Atom)
2 comments:
Thanks for this - I thought I was going crazy myself!
thanks for help.. this is really useful
Post a Comment