Hello !!
I am creating a dynamic textbox and want to validate it using the
requiredfieldva lidator.
These are the steps which I tried:
=============== =============== =============== =======
1) In Page_load,
Dim Email As New Label
Email.Text = "* Email Address"
placeHolder1.Co ntrols.Add(Emai l)
Dim txtEmailAddress As New TextBox
placeHolder2.Co ntrols.Add(txtE mailAddress )
2) The HTML has:
<tr><td>
<asp:PlaceHolde r ID="placeHolder 1" Runat="server"> </asp:PlaceHolder >
<asp:requiredfi eldvalidator id="reqFieldVal 1" runat="server"
Display="Dynami c" ErrorMessage="R equired"
ControlToValida te="txtEmailAdd ress"></asp:requiredfie ldvalidator>
</td>
</tr>
=============== =============== =============== =======
This gives an error message :
Unable to find control id 'txtEmailAddres s' referenced by the
'ControlToValid ate' property of 'reqFieldVal1'.
I tried the following options, but was unsuccessful:
a) Move requiredFieldVa lidator inside placeholder. (Googling around,
suggested that the validator and control should be in the same
container)
b) Tried to create requiredFieldVa lidator dynamically and add it in the
same placeholder (ie placeHolder1)
Any pointers will be appreciated !!
TIA..