sonny_j81
asked on
Dynamically created RegularExpressionValidator in c# code behind
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(txtEv alTitle);
phCriteriaDetails.Controls .Add(rev);
urgently need ur help..
Thanks
I wanna to dynamically add the RegularExpressionValidator
May i know how to do that?
actually i have test the RegularExpressionValidator
but once i write d RegularExpressionValidator
May i know how to write dynamic RegularExpressionValidator
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.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
phCriteriaDetails.Controls
urgently need ur help..
Thanks
ASKER
I put the code in button .....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Where is your code? I put mine in Page_Load.
David