views:

62

answers:

1

Hi I am having N numbers of Text boxes those are generating dynamically. I want to validate each textbox for Formate HH:MM:SS PM/AM so i dynamicaly create the validation control . but as the dynamic textbox has no ID , so what i have to pass to the Validation control for ControlToValidate Property ?

A: 

AccordionPane ap1; for (int i = 0; i <= 2; i++) { ap1 = new AccordionPane(); ap1.HeaderContainer.Controls.Add(new LiteralControl("Using Markup")); Panel pnl = new Panel();

                TextBox txtTime = new TextBox();
                txtTime.ID = "txtTimeBox" + i;
                txtTime.ValidationGroup = "MKE";
                RegularExpressionValidator validateDate = new RegularExpressionValidator();
                validateDate.ValidationExpression = "(0[1-9]|1[0-2]):([0-5][0-9]):([0-5][0-9]|60) (AM|PM|am|pm)";
                validateDate.ControlToValidate = txtTime.ID;
                validateDate.ErrorMessage = "Invalid Date. Try in HH:MM:SS AM/am|PM/pm format";

                pnl.Controls.Add(txtTime);
                ap1.ContentContainer.Controls.Add(pnl);
            MyAccordion.Panes.Add(ap1);
        }
        Page.Controls.Add(divContainer);
Lalit
this is my code. in dynamic N number of accordian ther are texboxes...those i want validate
Lalit
WELL ITS DONE NOW...
Lalit