Partial Page Post-Back and The Property Proxy Validator – CTD
November 18, 2009 Leave a comment
As a quick follow-up to this post, I disabled the PropertyProxyValidator on the RowUpdating Event Handler of the other control and it worked fine
protected void GridViewFamily_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
PropertyProxyValidator propertyProxyValidator =
GenericUtilities.FindAChildControl(this.DetailsViewInsertFamily, "PropertyProxyValidatorInsertPersonName") as PropertyProxyValidator;
propertyProxyValidator.Enabled = false;
}
FindaChildControl is a just a recursive method to find a control on a web page:
public static Control FindAChildControl(Control control, string controlId)
{
Control targetControl = null;
foreach (Control childControl in control.Controls)
{
if (childControl.ID == controlId)
{
targetControl = childControl;
}
if (targetControl == null && childControl.Controls.Count > 0)
{
targetControl = FindAChildControl(childControl, controlId);
}
}
return targetControl;
}
The fact that I have to do this is very annoying – it adds more code to the project, therefore increasing the cost to develop and maintain it. I noticed that the out of the box ASP.NET validators do not have this problem – they only fire when the control that they are associated is updating/inserting… I would argue that the Ent Lib validators need to add this feature.