This project has moved. For the latest updates, please go here.
1

Closed

Crash on RenderClientScript when ViewData is assigned

description

I'm getting a crash on any page that has a ViewData object example assigned to it i.e.:
public partial class SampleView : ViewPage <SampleViewData>
Closed Sep 17, 2009 at 3:58 PM by jbaurle

comments

Bill_G wrote Feb 15, 2008 at 10:11 PM

I named the function wrong in the title for some reason. It should be RenderValidationSetScripts.

djsneed31 wrote Mar 11, 2008 at 8:19 AM

I was having the same problem and I thought it had to do with this project, but I think it has to do with the System.Web.Mvc Extensions.

I was getting the following error: The view data passed into the page is of type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]' but this page requires view data of type '(MyDataObjectType)'

I changed my calling method from RenderView("MyView") to RenderView("MyView", new MyDataObject() and that fixed it. It seems that the overloads on the RenderView method try to send a Dictionary<string, object> to the ViewData property of the ViewPage. There is a conflict when you use the ViewPage<T> and don't pass the proper type of data. I don't know if this answers your question or not, but hopefully it will help someone out there.

JokerLash wrote Apr 16, 2008 at 11:00 AM

I have the same problem. When i tell my View that the ViewData object is of type X using: public partial class SampleView : ViewPage <SampleViewData>

when i call the RenderView("myView", new SampleViewData());
i still get an error stating: 'MvcValidatorToolkit.SampleSite.Controllers.SampleControllerViewData' does not contain a property with the name 'SampleXValidationSet'.

To solve this problem i added a property to my SampleViewData class called SampleValidationSet of type SampleValidationSet
eg:
public class SampleViewData
{
    public string Test { get; set; }
    public SampleValidationSet SampleValidationSet { get; set; }
}
But i don't think this is an ideal solution, can anyone supply a better one?

wrote Sep 17, 2009 at 3:58 PM

wrote Feb 13, 2013 at 11:16 PM

wrote May 16, 2013 at 5:04 AM