Custom Validators for Composite Controls
13 Jun 2007I have created several custom composite controls (containing multiple input fields) and validators for our website at work.
I needed the SetFocusOnError property to work on my customĀ validators, but it didn't work by default.Ā
I started to dig through ASP.NET's JavaScriptĀ code and found that if my custom composite controlĀ was enclosed inĀ a table tagĀ (instead of the default div tag)Ā that the JavaScriptĀ would search theĀ table tagĀ for input controls.
The following code will change the default enclosed tag from a div to a table.
public class LengthEditor : CompositeControl
{
protected override HtmlTextWriterTag TagKey
{
get { return HtmlTextWriterTag.Table; }
}
}