1

Closed

UninstallPackage removes pageBaseType from web.config

description

I couldnt get your helpers to work - I kept getting errors about couldnt infer types.
 
So I uninstalled the nuget package, and then my razor views show errors saying that pageBaseType is not defined in web.config, and all of the normal HTML helper calls are now saying that they cannot infer types.
Closed by

comments

frankabbruzzese wrote Aug 27, 2011 at 1:52 PM

1) Probably nuget was not able to restore some web.comfig file, to restore it try to create a new project and copy the web.config of the new project that is under the View folder in your project, in the same position. We used no customization of Nuget installation, so this should be a problem of Nuget that is not able to restore config files.
2) Please tell me what helpers you were not able to use. At moment there is no known issue involoving the helpers, so maybe you passed some wrong parameter, or there is something wrong in your Mvc installarion. Have you installed the Mvc3 tools update? If not this might explain problems you are experiencing in VS 2010 with Razor page.

RickHodder wrote Aug 28, 2011 at 2:43 AM

I was able to restore from s

I tried to use DualSelectFor and CheckBoxListFor:

For example, I copied the example from the documentation:

In a view that has

@model Dress

@Html.CheckBoxListFor(model => model.DressColors,
                    ChoiceListHelper.Create(
                            ((IEnumerable<DressColor>)ViewBag.PossibleDressColors), (t => t.ColorName), (t => t.ID)))
@Html.CheckBoxListFor is underlined with a red squiggle and the error message says .

(extension) MvcHtmlString HtmlHelper<Dress>.CheckBoxListFor<Dress,TChoiceItem,TValue,TDisplay>(System.Linq.Expressions.Expression<Func<Dress,IEnumerable<TValue>>> expression, ChoiceList<TChoiceItem,TValue,TDisplay> choicelist, [bool useTemplate=false], [object template=null], [object itemTemplate=null])

Error:
The type arguments for mend MVCControlsToolkit.Controls.CheckBoxListHelper.CheckBoxListFor<TModel,TChoiceItem,TValue,TDisplay>(System.Web.Mvc.HtmlHelper<TModel>System.Linq.Expressions.Expression<System.Func<TModel,System.Collections.Generic.IEnumerable<TValue>>>, MVCControlsToolkit.Core.ChoiceList<TChoiceItem,TValue,TDisplay>,bool, object,object)' cannot be inferred from the usage. Try specifiying the type arguments explicitly
public class Dress
{
    public int ID { get; set; }
    public int GalleryTypeID { get; set; }
    public virtual GalleryType GalleryType { get; set; }
    public int DressTypeID { get; set; }
    public virtual DressType DressType { get; set; }
    public int DesignerID { get; set; }
    public virtual Designer Designer { get; set; }
    public string Description { get; set; }
    public string DressName { get; set; }
    public string Bust { get; set; }
    public int DressLength { get; set; }
    public int SleeveLength { get; set; }
    public decimal Price { get; set; }
    public int Waist { get; set; }
    public int test { get; set; }
    public int PersonID {get;set;}
    public virtual Person Person { get; set; }

    public virtual ICollection<DressColor> DressColors { get; set; }
    public virtual ICollection<Picture> Pictures { get; set; }

}
public class DressColor
{
    public int ID { get; set; }
    public string ColorName { get; set; }

    public virtual ICollection<Dress> Dresses {get;set;}
}

frankabbruzzese wrote Aug 28, 2011 at 1:26 PM

You have done a common error. You passed to CheckBoxListFor, model => model.DressColors, as first argument. This is a list of DressColor objects, while you should have passed a List containing just The ID of the DressColor objects. CheckBoxListFor and DualSelectFor works as the standard DropDown helper they works just with the ID of the objects. The whole objects must be contained just in the list of all possible choices.
The error you get is misleading, but whenever VS 2010 find a type mismatch in an expressions that contains Generics it produces this errors because it is not able to give to all Generics a type that satisfies the the method definition....The message is misleading, because VS 2010 is not able to infer the types of the generics,....but just because the user provided a wrong argument.