P
peshrad
Hi !
I'm using Visual Studio 2000,
Win2K, IE 6, .NET 1.1.
I'm experimenting with an extremely simple ASP.NET web application.
When I add a CustomValidator to the designer by drag&drop,
I can accomplish both client-side and subsequent server-side validation.
At run-time, when I press my submit button,
first my JavaScript function is called for validation,
later my C# event handler is called in the server-side code.
However, when I add the CustomValidator at run-time,
only client-side validation works.
How can I fix this problem ?
Here comes the code that creates the CustomValidator at run-time.
The function cv_2_ServerValidate is never called later.
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
CustomValidator cv = new CustomValidator();
cv.ID = "cv_2";
cv.ControlToValidate = "TextBox1";
cv.ErrorMessage = "Another input error!";
cv.ServerValidate +=new
ServerValidateEventHandler(cv_2_ServerValidate);
cv.ClientValidationFunction = "doClientValidation";
TextBox1.Parent.Controls.Add(cv);
}
}
Your kind advice would be appreciated.
Peter
I'm using Visual Studio 2000,
Win2K, IE 6, .NET 1.1.
I'm experimenting with an extremely simple ASP.NET web application.
When I add a CustomValidator to the designer by drag&drop,
I can accomplish both client-side and subsequent server-side validation.
At run-time, when I press my submit button,
first my JavaScript function is called for validation,
later my C# event handler is called in the server-side code.
However, when I add the CustomValidator at run-time,
only client-side validation works.
How can I fix this problem ?
Here comes the code that creates the CustomValidator at run-time.
The function cv_2_ServerValidate is never called later.
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
CustomValidator cv = new CustomValidator();
cv.ID = "cv_2";
cv.ControlToValidate = "TextBox1";
cv.ErrorMessage = "Another input error!";
cv.ServerValidate +=new
ServerValidateEventHandler(cv_2_ServerValidate);
cv.ClientValidationFunction = "doClientValidation";
TextBox1.Parent.Controls.Add(cv);
}
}
Your kind advice would be appreciated.
Peter