why this error occours ?
Object reference not set to an instance of an objec
Although i m getting correct ID of both controlls.
d2 = this.Page.FindControl("ctl00$ContentPlaceHolder1$DtCal").ID.ToString();
d1 = this.Page.FindControl("ctl00$ContentPlaceHolder1$useDateCal").ID.ToString();
CompareValidator validator = new CompareValidator();
validator.ID = "validation";
validator.ControlToCompare = d1;
validator.ControlToValidate = d2;
validator.Attributes.Add("Type", "Integer");
validator.Attributes.Add("runat","server");
validator.Attributes.Add("ErrorMessage","date2 Should be greater");
validator.Text = "date2 Should be greater";
validator.Attributes.Add("Display","Dynamic");
validator.Attributes.Add("Operator","GreaterThan");
validator.Attributes.Add("style","color:Red;visibility:hidden");
validator.Enabled = true;
validator.IsValid=true;
validator.EnableViewState=true;
validator.Visible=true;
validator.Validate();.//...Error...Object reference not set to an instance of an objec