G
Gonza
Hi group, i'm trying to add a customvalidator control to a custom web
control. The problem is i'm getting a "Unable to find control id..."
exception. Here is the code:
public class CuitTextBox : WebControl
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
protected override void OnPreRender(EventArgs e)
{
Control numericTextBox =
Page.LoadControl("~/WebControls/NumericTextBox.ascx");
TextBox underliyingText =
numericTextBox.FindControl("txtTextBox") as TextBox;
CustomValidator validator = new CustomValidator();
validator.ControlToValidate = underliyingText.ClientID;
validator.ErrorMessage = "El CUIT ingresado es invalido";
validator.ClientValidationFunction = "ValidateCuit";
validator.Visible = true;
validator.Enabled = true;
validator.EnableClientScript = true;
Controls.Add(validator);
Controls.Add(numericTextBox);
PageUIHelper.RegisterJsUtilFile(Page);
base.OnPreRender(e);
}
}
Thanks in advance for any help
control. The problem is i'm getting a "Unable to find control id..."
exception. Here is the code:
public class CuitTextBox : WebControl
{
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
protected override void OnPreRender(EventArgs e)
{
Control numericTextBox =
Page.LoadControl("~/WebControls/NumericTextBox.ascx");
TextBox underliyingText =
numericTextBox.FindControl("txtTextBox") as TextBox;
CustomValidator validator = new CustomValidator();
validator.ControlToValidate = underliyingText.ClientID;
validator.ErrorMessage = "El CUIT ingresado es invalido";
validator.ClientValidationFunction = "ValidateCuit";
validator.Visible = true;
validator.Enabled = true;
validator.EnableClientScript = true;
Controls.Add(validator);
Controls.Add(numericTextBox);
PageUIHelper.RegisterJsUtilFile(Page);
base.OnPreRender(e);
}
}
Thanks in advance for any help