c# - validation control unable to find its control to validate -


i have repeater bound number of custom dataitems/types

on itemdatabound event repeater code calls renderedit function depending on custom datatype render custom control. (if validation flag set) render validation control appropriate rendered edit control

the edit control overrides createchildcontrols() method custom control adding number of literalcontrols thus

protected override void createchildcontrols() {     //other bits removed - 'hidden' control trying validate     this.controls.add(new literalcontrol(string.format(                                          "<input type=\"text\" name=\"{0}\" id=\"{0}\" value=\"{1}\" style=\"display:none;\" \">"                                          , this.uniqueid                                          , this.mediaid.tostring())                                          ));     //some other bits removed } 

the validation control rendered this: passed in editcontrol control instance of above createchildcontrols method of..

public override control rendervalidationcontrol(control editcontrol) {     control ctrl = new placeholder();      requiredfieldvalidator req = new requiredfieldvalidator();     req.id = editcontrol.clientid + "_validator";     req.controltovalidate = editcontrol.uniqueid;     req.display = validatordisplay.dynamic;     req.initialvalue = "0";     req.errormessage = this.caption + " cannot blank";     ctrl.controls.add(req);      return ctrl; } 

the problem is, altho validation controls .controltovalidate property set uniqueid of editcontrol. when hit page following error: unable find control id 'fieldrepeater$ctl01$ctl00' referenced 'controltovalidate' property of 'fieldrepeater_ctl01_ctl00_validator'.

i have tried changing literal in createchildcontrols new textbox(), , set id etc then, similar problem.

can enlighten me? because of order controls rendered in? ie validation control written before editcontrol? or...

anyhow appreciated

thanks

nat

you have use editcontrol.id not editcontrol.uniqueid

also take account if editcontrol must can used required field vaidator. doesn't make sense validator input controls.

edit
check link. may helpful since it's exaclty need
http://support.microsoft.com/kb/310082


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -