Hi, I have a button that is assigned to a validation group that runs a bunch of custom validators and puts all their errors into one validation summary. I was wondering since the button has the validationgroup property set as "vg" how do I reference this
in Code Behind? ie..... if validation group isvalid .....else.......
mkfost
Member
4 Points
29 Posts
Referencing Validity of Validation Group in Codebehind
Sep 10, 2007 08:48 AM|LINK
Hi, I have a button that is assigned to a validation group that runs a bunch of custom validators and puts all their errors into one validation summary. I was wondering since the button has the validationgroup property set as "vg" how do I reference this in Code Behind? ie..... if validation group isvalid .....else.......
Thanks
hkhaled
Contributor
3024 Points
461 Posts
Re: Referencing Validity of Validation Group in Codebehind
Sep 10, 2007 11:06 AM|LINK
visit the link bellow this may help:
http://www.codeproject.com/aspnet/groupvalidator.asp
thanks
mkfost
Member
4 Points
29 Posts
Re: Referencing Validity of Validation Group in Codebehind
Sep 10, 2007 03:21 PM|LINK
N/m, it was simply If Page.IsValid = True, which i could have sworn I tried before, anyway, working now! :)
AlfredQ
Member
4 Points
3 Posts
Re: Referencing Validity of Validation Group in Codebehind
Feb 04, 2013 08:25 AM|LINK
Could try this way
//**************************************************
private Boolean GrupoValido()
{
Boolean lIndRetorno = true;
Page.Validate();
foreach (BaseValidator oRefBVValidador in Page.Validators)
{
if (oRefBVValidador.ValidationGroup == "GrupoValidacion")
{
if (oRefBVValidador.Visible == true)
{
if (oRefBVValidador.IsValid == false)
{
lIndRetorno = false;
break;
}
}
}
}
return lIndRetorno;
}
//**************************************************
protected void CoBtAgregar_Click(object sender, EventArgs e)
{
if (GrupoValido() == true)
{
if (RegistrarDatos() == true)
{
//Datos Salvados
}
}
}