Love answering my own questions:
[ValidationPrope rty("Validation Text")]
public partial class PhoneUserContro l : System.Web.UI.U serControl
{
protected void Page_Load(objec t sender, EventArgs e) { }
const string template = "({0}) {1}-{2}";
public string FormattedText
{
get { return string.Format(t emplate, TextBoxAreaCode .Text,
TextBoxPrefix.T ext, TextBoxSuffix.T ext); }
}
public string ValidationText
{
get
{
if (TextBoxAreaCod e.Text.Length != 3 ||
TextBoxPrefix.T ext.Length != 3 || TextBoxSuffix.T ext.Length != 4)
{
return string.Empty;
}
return TextBoxAreaCode .Text + TextBoxPrefix.T ext +
TextBoxSuffix.T ext;
}
}
}
"Andrew Robinson" <ne****@nospam. nospamwrote in message
news:uD******** ******@TK2MSFTN GP05.phx.gbl...
Is it possible to have a RequiredFieldVa lidator that targets a
UserControl?
<asp:RequiredFi eldValidator ID="RequiredFie ldValidator6" runat="server"
ControlToValida te="PhoneUserCo ntrolHome" Display="dynami c"
Text=" (Re quired Field)" />
This code generates a run time exception of "Control
'PhoneUserContr olHome' referenced by the ControlToValida te property of
'RequiredFieldV alidator6' cannot be validated. "
Thanks,