How to create requirevalidation programatically???

  • Thread starter Thread starter Hai Nguyen
  • Start date Start date
H

Hai Nguyen

Hi everyone

I'm building a web application which create a lot of HTML textboxes (not
datagrid) to get input from user. Being assosiate with a textboxe is a
requiredfield validator. The code is below. I don't know why after hitting
submit button, it does show me the error such as "*" symbol next to the box.
After I filled out those textboxes again and hit button to process the page.
It does not do anything, look like still waiting for an event.

RequiredFieldValidator dateValid = new RequiredFieldValidator();

dateValid.ID = "required" + stringID ;

dateValid.ControlToValidate = stringID;

//Response.Write(dateValid.ClientID+"<br>");

dateValid.Display = ValidatorDisplay.Dynamic;



I would like to ask for a solution.



Thanks
 
Hai Nguyen said:
Hi everyone

I'm building a web application which create a lot of HTML textboxes (not
datagrid) to get input from user. Being assosiate with a textboxe is a
requiredfield validator. The code is below. I don't know why after hitting
submit button, it does show me the error such as "*" symbol next to the box.
After I filled out those textboxes again and hit button to process the page.
It does not do anything, look like still waiting for an event.

RequiredFieldValidator dateValid = new RequiredFieldValidator();

dateValid.ID = "required" + stringID ;

dateValid.ControlToValidate = stringID;

//Response.Write(dateValid.ClientID+"<br>");

dateValid.Display = ValidatorDisplay.Dynamic;



I would like to ask for a solution.



Thanks

You didn't specify it, so I'll just say the obvious:
stringID should be the ID of the TextBox you are trying to validate
(yourTextBox.ID)

Your code seems ok, you apparently add the validator to the page
(as you see the errormessage). The validators stop a submit if the
page is not valid (and this also seems to happen).
You might want to add your own messages.
Are there more validators that block the submit?

Hans Kesting
 
Back
Top