Dynamically add validation controls
Posted on 2004-08-02
I've got a form with few controls which are added in the design time.. Based on the user input, I add few more controls dynamically which works fine.
What I need is to add validation controls to these dynamic controls. I tried doing this but it doesn't work..
RequiredFieldValidator ReqVal = new RequiredFieldValidator();
ReqVal.ControlToValidate = FieldID;
ReqVal.Display = System.Web.UI.WebControls.ValidatorDisplay.Dynamic;
ReqVal.ErrorMessage = FieldName + " is Mandatory!";
I reckon when I see the source of the page once loaded, I should see these validation controls across the element.. which I'm not getting.. What is that I'm missing? Pls help..