Validator not working with configuration file.

Topics: Validation Application Block
May 17, 2007 at 2:15 PM
I already followed the quickstart, I have read a lot of doccumentation and I just give up, the scensario is, I have a web project which references a class library, the busines entitites are implemented on the class library, the library also has a businesslogic implementation, and this one is the one that the codebehind uses, then the business logic calls the data layer to insert on tables.

I have this on the web.config
<validation>
<type assemblyName="LibPruebaEL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
name="Avansoft.Cifin2.BusinessObjects.Perfil">
<ruleset name="Regla">
<properties>
<property name="DSPerfil">
<validator lowerBound="1" lowerBoundType="Ignore" upperBound="3"
upperBoundType="Inclusive" negated="false" messageTemplate="Máximo 3 carácteres."
messageTemplateResourceName="" messageTemplateResourceType=""
tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.StringLengthValidator, Microsoft.Practices.EnterpriseLibrary.Validation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="String Length Validator" />
</property>
</properties>
</ruleset>
</type>
</validation>

and this on a page
<cc1:PropertyProxyValidator ID="PropertyProxyValidator1" runat="server" ControlToValidate="TextBox1"
PropertyName="DSPerfil" RulesetName="Regla" SourceTypeName="Avansoft.Cifin2.BusinessObjects.Perfil" SpecificationSource="Configuration"></cc1:PropertyProxyValidator></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

but the validator never shows the message and always inserts the record.

My code behind is this.
Page.Validate();
if(Page.IsValid)
{

BLPerfil objBlPerfil = new BLPerfil();
Perfil objPerfil = new Perfil();
objPerfil.IdPrioridad = Convert.ToInt32(TextBox2.Text);
objPerfil.DSPerfil = TextBox1.Text;
objBlPerfil.Ingresar(objPerfil);
GridView1.DataBind();
}
May 17, 2007 at 2:47 PM
I found why, but I need somebody to gives me an explanation please.

If I remove this from the validation section
, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

and from the config section, it works. Otherwise it doesnt!!

Strange for me!!