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

Closed

this.RenderValidationSetScripts() Problem

description

I don't know if I'm doing something wrong (but I've poured over the sample 4 in the toolkit several times), but in my MVC ASP.NET Project, every time my View renders, I get this error because it doesn't recognize the 2 ValidationSet classes I've specified as attributes to my ViewPage:
 
DataBinding: 'System.String[]' does not contain a property with the name 'Form1Validation'.
 
I have the following in the code-behind for my view:
 
[ValidationSet(typeof(Form1Validation))]
[ValidationSet(typeof(Form2Validation))]
public partial class ValidationExample : ViewPage
{
}
 
In my View, I have:
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
 
<script type="text/javascript" src="../../content/js//ValidationExample.js"></script>
 
<form id="Form1" action="/Validation/Form1Processing/" method="post">
 
...
 
<% this.RenderValidationSetScripts(); %>
 
</asp:Content>
 
In my ValidationSet class I have:
 
using System;
using System.Web.Mvc;
 
namespace MyProjectName.ValidationSets
{
public class Form1Validation : ValidationSet
{
    protected override ValidatorCollection GetValidators()
    {
        return new ValidatorCollection
        (
            new ValidateElement("txtEmail") { Required = true }
        );
    }
}
 
public class Form2Validation : ValidationSet
{
    protected override ValidatorCollection GetValidators()
    {
        return new ValidatorCollection
        (
            new ValidateElement("txtEmail2") { Required = true }
        );
    }
}
}
 
My .js file has:
 
$(document).ready(function()
{
$(function(){
    updateSettingsForForm1Validation($('#Form1').validate({
        errorPlacement:function(error,element){
            error.appendTo(element.parent("td").next("td"));
        },
        rules:{}
    }));
    updateSettingsForForm2Validation($('#Form2').validate({
        errorPlacement:function(error,element){
            error.appendTo(element.parent("td").next("td"));
        },
        rules:{}
    }));
});  
 
....
 
});
Closed Sep 17, 2009 at 4:03 PM by jbaurle

comments