c# - How to set dynamically textbox required -
i created dynamically text boxes. must field user. want add "requiredfieldvalidator". dont know how add dynamically .user can't go next step without filling these dynamically text boxes. how can control this?
this code
(int = count; < no; i++) { label lb = new label(); lb.id = "lbfname" + numberofcontrols; lb.text = "first name :"; textbox tbx = new textbox(); tbx.id = "fname" + numberofcontrols; adultslistplaceholder.controls.add(lb); adultslistplaceholder.controls.add(tbx); numberofcontrols++; adultslistplaceholder.controls.add(new literalcontrol("<br />")); adultslistplaceholder.controls.add(new literalcontrol("<br />")); }
any idea?
try this..
requiredfieldvalidator req = new requiredfieldvalidator(); req.id = "req" + numberofcontrols;; req.controltovalidate = "fname" + numberofcontrols;; req.errormessage = "name required"; reqfldval.setfocusonerror = true; adultslistplaceholder.controls.add(req);
Comments
Post a Comment