troubleshooting Question

Dynamically created RegularExpressionValidator in c# code behind

Avatar of sonny_j81
sonny_j81 asked on
C#
3 Comments1 Solution2864 ViewsLast Modified:
Dear Expert,

I wanna to dynamically add the RegularExpressionValidator in c# code behind..
May i know how to do that?
actually i have test the RegularExpressionValidator in html there..It can get d result that i want.
but once i write d RegularExpressionValidator in code behind it, the regular expression didnt appear when i key in wrong number.
May i know how to write dynamic RegularExpressionValidator?Do i need to write txtEvalTitle_onTextChanged ?

Bellow is my code:

                            TextBox txtEvalTitle = new TextBox();
                            txtEvalTitle.ID = "txtEvalTitle" + arrCriteriaDetails[i, 5];  
                            txtEvalTitle.Font.Bold = true;
                            txtEvalTitle.Font.Size = 10;
                            txtEvalTitle.Width = 30;
                            txtEvalTitle.Text = arrCriteriaDetails[i, 3];
                            RegularExpressionValidator rev = new RegularExpressionValidator();
                            rev.ID = "rev" + arrCriteriaDetails[i, 3];
                            rev.ControlToValidate = "txtEvalTitle" + arrCriteriaDetails[i, 5];
                            rev.ErrorMessage = "Please Enter Title No";
                            rev.ValidationExpression = "[-+]?([1-9]*\\.0+)";
                            rev.Visible = true;
                           
                            phCriteriaDetails.Controls.Add(txtEvalTitle);
                           
                            phCriteriaDetails.Controls.Add(rev);  


urgently need ur help..
Thanks
ASKER CERTIFIED SOLUTION
anyoneis
Software Developer
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros