Click here to Skip to main content
15,889,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm creating dynamic controls of webform and also validations but those were not firing i kept validation group for a static button and required validation here is my code



switch (dr["DATATYPE"].ToString())
{
case "int":
case "string":
TextBox tb = new TextBox();
tb.ID = dr["FIELDNAME"].ToString();
td1.Controls.Add(tb);
if(flag=="show")
tb.Text = _frmElement.Element(dr["FIELDNAME"].ToString()).Value;
else if (flag == "new")
tb.Text = "";



//--- validations

if (dr["ISMANDATORY"].ToString() != (1).ToString())
{
RequiredFieldValidator rq = new RequiredFieldValidator();
rq.ControlToValidate = tb.ID;
rq.ErrorMessage = "This fields are required";
rq.ValidationGroup = "a";
}

//--validations
break;
<asp: button id="Btnsave" runat="server" validationgroup="a">


Why so im not able to do validations
Posted
Comments
thursunamy 15-May-14 10:51am    
http://stackoverflow.com/questions/1164484/validation-on-dynamic-controls

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900