|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
validatingHi,
I am reading an XML file and creating a form (ie. putting text fields/radio buttons, etc.). I would like to validate the Text Fields but the RequiredValidator requires me to specify the name of the field. My text fields are dynamically created . Any help would be greatly appreciated. I am using C#. Shahid Hi,
you can still assign those dynamically created controls an ID and pass this ID also to the validator control. That way it knows which control to validate. If you have some sort of repeating happening and you don't use built-in databound controls such as repeater helping you, you'd probably need to manage the ID naming yourself, means that add an row index to the ID or something so that they are kept unique. I was able to generate it dynamically and also tried to generate the
RequiredFieldValidator, but it doesn't validate. This is what I have: req[x] = new RequiredFieldValidator(); req[x].ID = "score_" + (i+1) + "_" + (x+1); req[x].ControlToValidate = "score_" + (i+1) + "_" + (x+1); req[x].ErrorMessage = "Please enter the score"; PlaceHolder2.Controls.Add(req[x]);
Other interesting topics
Code-Behind Pain in the Behind!
Best way to disable a site? Authentication mode in web.config causing crash. Dynamically position custom control .ascx Message Box in ASP Options for generic full-text search without using database-specific full-text engine? Is there server control that you load with HTML from a URL Firefox Validation Issue - not the standard document.[all] problem! Dataview returns 0 rows Server.MapPath from a vb class |
|||||||||||||||||||||||